nginx - 如何正确调试哨兵并找到 502 nginx 错误的原因
问题描述
我是哨兵和 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
您可能会对此主题感兴趣: 论坛哨兵
推荐阅读
- ruby-on-rails - 使用原生扩展安装 mysql2 0.4.10 Gem::Ext::BuildError: ERROR: Failed to build gem native extension
- javascript - 基于数组中的数组合并数组中的javascript对象
- javascript - 导出整个 CONST js
- javascript - 如何使用javascript在firebase数据库中上传变量作为属性名称?
- autodesk-forge - 从 IFC 转换为 SVF 后,Autodesk Forge 中是否可以使用 IfcOpeningElements?
- python - 使用 Music 21 和 Python 输出不止一种乐器
- reactjs - Webpack 和 Lighthouse 性能测试
- azure - Azure VM:无法安装 Qualys 扩展
- python - 为什么 else 在这个简单的代码中显示为语法错误?
- excel - 将表数据从 access 导出到 excel