如何正确调试sentry并查找502 nginx错误的原因

How to properly debug sentry and find cause for 502 nginx error

我是 sentry 和 Nginx 的新手,我很难弄清楚我的实例中发生了什么,以及为什么我从 Nginx 收到 502。

在哪里可以找到问题的根源?我尝试使用 tail -100 /var/log/nginx/error.log 但我看不出问题出在哪里...

来自tail /var/log/nginx/error.log的输出:

2021/04/30 17:08:55 [error] 68825#68825: *7 upstream timed out (110: Connection timed out) while connecting to upstream, client: 172.28.132.95, server: mydomain.com, request: "GET / HTTP/1.1", upstream: "https://myip:9000/", host: "mydomain.com"
2021/04/30 17:09:08 [alert] 68825#68825: *17 open socket #9 left in connection 3
2021/04/30 17:09:08 [alert] 68825#68825: *16 open socket #8 left in connection 4
2021/04/30 17:09:08 [alert] 68825#68825: *15 open socket #13 left in connection 5
2021/04/30 17:09:08 [alert] 68825#68825: aborting

我发现的唯一奇怪的事情是 upstream 使用我的实例 IP 地址并且主机被解析为 mydomain.com

我的 Nginx /etc/nginx/sites-available/default:

    server {
      server_name mydomain.com;
      location / {
        proxy_pass         http://localhost:9000;
        proxy_redirect     off;
        proxy_set_header   Host              $host;
        proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
      }
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/mydomain/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mydomain/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 = mydom) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
      listen 80;
      server_name mydomain.com;
    return 404; # managed by Certbot
}

docker-compose.yml (nginx):

      nginx:
    <<: *restart_policy
    ports:
      - '127.0.0.1:$SENTRY_BIND:80/tcp'
    image: "nginx:1.16"
    volumes:
      - type: bind
        read_only: true
        source: ./nginx
        target: /etc/nginx
    depends_on:
      - web
      - relay

system.internal-url-前缀:

system.internal-url-prefix: 'https://mydomain:9000'

sentry.conf.py :

##############
# Web Server #
##############

SENTRY_WEB_HOST = "0.0.0.0"
SENTRY_WEB_PORT = 9000
SENTRY_WEB_OPTIONS = {
    "http": "%s:%s" % (SENTRY_WEB_HOST, SENTRY_WEB_PORT),
    "protocol": "uwsgi",
    # This is needed in order to prevent https://git.io/fj7Lw
    "uwsgi-socket": None,
    "so-keepalive": True,
    # Keep this between 15s-75s as that's what Relay supports
    "http-keepalive": 15,
    "http-chunked-input": True,
    # the number of web workers
    "workers": 3,
    "threads": 4,
    "memory-report": False,
    # Some stuff so uwsgi will cycle workers sensibly
    "max-requests": 100000,
    "max-requests-delta": 500,
    "max-worker-lifetime": 86400,
    # Duplicate options from sentry default just so we don't get
    # bit by sentry changing a default value that we depend on.
    "thunder-lock": True,
    "log-x-forwarded-for": False,
    "buffer-size": 32768,
    "limit-post": 209715200,
    "disable-logging": True,
    "reload-on-rss": 600,
    "ignore-sigpipe": True,
    "ignore-write-errors": True,
    "disable-write-exception": True,
}

###########
# SSL/TLS #
###########

# If you're using a reverse SSL proxy, you should enable the X-Forwarded-Proto
# header and enable the settings below

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SOCIAL_AUTH_REDIRECT_IS_HTTPS = True

有什么我可能遗漏的想法吗?

在此先致谢并致以诚挚的问候

你可以试试docker-compose logs web relay

这个主题可能是您感兴趣的: forum sentry