我有一个在 Docker 上容器化的 NodeJS (ExpressJS) 应用程序,它通过同样在 Docker 上容器化的 NGINX 反向代理公开。有时,发送到 NGINX 的请求需要 60 秒才能发送到应用程序。在 Sentry 上的监控中,我看到服务器在 600 毫秒内响应了请求,但在浏览器上下载时间为 61 秒。
这是我的 Nginx 配置
worker_processes 1;
error_log /dev/stderr warn;
events {
worker_connections 1024;
}
# make sure to set plaintext JWT_SECRET environment variable
env JWT_SECRET;
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout main;
lua_package_path "/usr/local/openresty/lualib/?.lua;;";
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS +RC4 RC4";
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# API
upstream application_server {
server application_server _1:3000 max_fails=1 fail_timeout=5s;
server application_server _8:3000 max_fails=1 fail_timeout=5s;
server application_server _2:3000 max_fails=1 fail_timeout=5s;
server application_server _3:3000 max_fails=1 fail_timeout=5s;
server application_server _4:3000 max_fails=1 fail_timeout=5s;
server application_server _5:3000 max_fails=1 fail_timeout=5s;
server application_server _6:3000 max_fails=1 fail_timeout=5s;
server application_server _7:3000 max_fails=1 fail_timeout=5s;
}
server {
listen 443 ssl http2;
server_name api.application.dev;
client_max_body_size 200M;
ssl_certificate /etc/letsencrypt/live/api.application.dev/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/api.application.dev/privkey.pem;
location / {
expires -1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $remote_addr;
proxy_pass http://application_server;
}
}
}
我该怎么做才能进一步追踪并修复此问题?