getsentry / self-hosted

Sentry, feature-complete and packaged up for low-volume deployments and proofs-of-concept
https://develop.sentry.dev/self-hosted/
Other
7.85k stars 1.77k forks source link

After restarting docker-compose get CORS policy Issue #1161

Closed marksitko closed 2 years ago

marksitko commented 2 years ago

Environment

self-hosted (onpremise deployment)

Version

21.10.0

Steps to Reproduce

View weeks ago i have set up the self-hosted sentry enviornment for my multi tenant app. It is provided with a Laravel backend and a dedicated VueJS Frontend. Everything works fine until i yesterday changed my SMTP settings in sentry/config.yml and then ran docker-compose restart. Containers are all started and healthy.

// This way sentry is integraded in the frontend
import Vue from 'vue';
import * as Sentry from '@sentry/vue';
import { Integrations } from '@sentry/tracing';

export default router => {
  Sentry.init({
    Vue,
    dsn: 'https://<DSN>@sentry.valcom.org/3',
    integrations: [
      new Integrations.BrowserTracing({
        routingInstrumentation: Sentry.vueRouterInstrumentation(router),
        // remove the last character because it's always an slash
        tracingOrigins: [process.env.VUE_APP_API_BASE_URL.slice(0, -1)], // VUE_APP_API_BASE_URL = backend.valcom.org/
      }),
    ],
    // Set tracesSampleRate to 1.0 to capture 100%
    // of transactions for performance monitoring.
    // We recommend adjusting this value in production
    tracesSampleRate: 1.0,
  });
};

My nginx config for the self-hosted sentry server

server {
    server_name MY_SENTRY_DOMAIN;
    proxy_set_header      X-Real-IP $remote_addr;
    proxy_set_header      X-Forwarded-For $proxy_add_x_forwarded_for;
    charset utf-8;

    location / {
    proxy_pass        http://localhost:9000;
    add_header Strict-Transport-Security "max-age=31536000";
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/MY_SENTRY_DOMAIN/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/MY_SENTRY_DOMAIN/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = MY_SENTRY_DOMAIN) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    server_name MY_SENTRY_DOMAIN;
    listen 80;
    return 404; # managed by Certbot
}

Bildschirmfoto 2021-11-19 um 09 15 44

Expected Result

Requests are not blocked and bug tracking should work as before and as expected.

Actual Result

Every request from the frontend is blocked by cors policy.

Access to fetch at 'https://sentry.valcom.org/api/3/store/?sentry_key=<DSN>&sentry_version=7' from origin 'https://demo.valcom.org' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Backend also don't track errors anymore. Even from local development or from production.

From the time i randocker-compose restart my sentry dashboard stopped receive new issues.

getsentry-release commented 2 years ago

Routing to @getsentry/team-webplatform for triage. ⏲️

rhcarvalho commented 2 years ago

Hi @masinette, hi @marksitko -- this is not something in the scope of the Web team, doesn't seem to be an SDK issue but rather environment / Sentry self-hosted setup. Re-routing.

getsentry-release commented 2 years ago

Routing to @getsentry/open-source for triage. ⏲️

chadwhitacre commented 2 years ago

Thanks @rhcarvalho @masinette, transferring to onpremise repo ...

chadwhitacre commented 2 years ago

I changed my SMTP settings in sentry/config.yml and then ran docker-compose restart

I take it the SMTP settings change is not implicated. From the screenshot it looks like all of the images were created 4 weeks ago so there doesn't seem to be a question of rebuilding images introducing a code change, correct? Did anything else change? Version of Sentry Vue SDK? Anything else on the frontend? 🤔

marksitko commented 2 years ago

Yes that's right, there are no code changes so it's not about rebuilding.

Thats the strange think, there is no changes on the frontend or with the Vue SDK. Installed are @sentry/tracing @sentry/vue with version 6.13.3

Since from restarting docker containers it doesn't track anything, you can see it in the screenshot, the last issue is 3 days ago, this was the time at which it was restarted. image

I just also found out that tracking for the "internal" project does not work either. image

From the logs from sentry_nginx_1 container i found that error message, maybe it helps you to identify the problem

[error] 22#22: *12713 connect() failed (111: Connection refused) while connecting to upstream, client: 172.18.0.1, server: , request: "POST /api/1/envelope/?sentry_key=<KEY>&sentry_version=7 HTTP/1.0", upstream: "http://172.18.0.25:3000/api/1/envelope/?sentry_key=<KEY>&sentry_version=7", host: "localhost:9000", referrer: "https://sentry.valcom.org/organizations/valcom/projects/"
aminvakil commented 2 years ago

I suspect there's something wrong with host nginx configuration. Try this: outside of server:

upstream senti {
  keepalive 32; # keepalive connections
  server 127.0.0.1:9000; # senti ip and port
}

in your server:

        location / {
               proxy_pass       http://senti/;
               proxy_redirect     default;
               proxy_http_version 1.1;

               proxy_set_header   Connection        $connection_upgrade;
               proxy_set_header   Upgrade           $http_upgrade;

               proxy_set_header   Host              $host;
               proxy_set_header   X-Real-IP         $remote_addr;
               proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
               proxy_set_header   X-Forwarded-Proto $scheme;
               proxy_max_temp_file_size 0;

               #this is the maximum upload size
               client_max_body_size       10m;
               client_body_buffer_size    128k;

               proxy_connect_timeout      90;
               proxy_send_timeout         90;
               proxy_read_timeout         90;
               proxy_buffering            off;
               proxy_request_buffering    off; # Required for HTTP CLI commands
        }
marksitko commented 2 years ago

I did a little bit research and found an post in the sentry form with a solution that helped me out. It may that the kafka forwarder gets into a bad state.

For anyone else run into the same issue, here is the solution that works for me: https://forum.sentry.io/t/sentry-no-more-catch-errors/10500/10

Thanks for helping. Issue can be closed.