我有一个应用程序尝试从 Javascript 应用程序发出 ajax 请求,以从 nginx 服务器检索 xml 文件。通常一切都很好,但我经常在 nginx 日志中看到错误(并从我的应用程序错误报告中获取错误),nginx 在获取期间遇到超时:
2015/11/16 21:15:21 [error] 1208#0: *4894044 upstream timed out (110: Connection timed out) while connecting to upstream, client: 209.95.138.54, server: www.servername.com, request: "GET /Shape%20Textures/Metal/Born%20to%20Shine.jpg?agentView=436314 HTTP/1.1", upstream: "http://127.0.0.1:3000/AQO/Shape%20Textures/Metal/Born%20to%20Shine.jpg?agentView=436314", host: "www.servername.com.com", referrer: "https://www.servername.com.com/?nid=39956&mode=edit"
我们有时也会遇到类似的错误:
2015/11/17 19:03:16 [error] 1002#0: *54042 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 137.164.121.52, server: www.servername.com, request: "POST /projects/?q=node/36375/update_project_time_and_stats HTTP/1.1", upstream: "http://127.0.0.1:3000/projects/?q=node/36375/update_project_time_and_stats", host: "www.servername.com", referrer: "https://www.servername.com/AQO/?nid=36375&mode=edit"
我似乎有类似的帖子,具有类似的超时,但所有这些帖子似乎都是可复制的。这个问题从来没有发生在我身上,但在实时服务器上运行时,我每天会看到 5-30 个这样的超时。
这是我的 nginx 配置:
client_max_body_size 50M;
server {
server_name servername.com;
return 301 $scheme://www.servername.com$request_uri;
}
server {
listen 80;
listen 443 ssl;
fastcgi_read_timeout 120;
ssl_certificate /path/to/ssl/star_servername_com.pem;
ssl_certificate_key /path/to/ssl/star_servername_com.key;
# Redirect all non-SSL traffic to SSL.
if ($ssl_protocol = "") {
rewrite ^ https://$host$request_uri? permanent;
}
root /usr/share/nginx/html;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name www.servername.com;
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://127.0.0.1:3000;
proxy_read_timeout 120s;
}
}
由于我无法重现它,我想知道如何才能找到这个问题?
最佳答案
upstream timed out (110: Connection timed out) while connecting to upstream
表示你的上游服务器没有及时接受连接
upstream timed out (110: Connection timed out) while reading response header from upstream
表示你的上游服务器没有及时回复
因此请检查您的上游服务器(127.0.0.1:3000)。它可能设置了少量传入连接或某种 DDoS 保护或当前负载非常重或其他情况。
关于nginx - nginx 服务器上不一致的超时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33745981/