我将Puma作为上游应用服务器运行,将Riak作为后台数据库集群运行.当我发送一个请求map - 减少大约25K用户的数据块并将其从Riak返回给应用程序时,我在Nginx日志中收到错误:
上游超时(110:连接超时),同时从上游读取响应头
如果我在没有nginx代理的情况下直接查询我的上游,使用相同的请求,我会得到所需的数据.
一旦放入代理,就会发生Nginx超时.
**nginx.conf**
http {
keepalive_timeout 10m;
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
fastcgi_send_timeout 600s;
fastcgi_read_timeout 600s;
include /etc/nginx/sites-enabled/*.conf;
}
**virtual host conf**
upstream ss_api {
server 127.0.0.1:3000 max_fails=0 fail_timeout=600;
}
server {
listen 81;
server_name xxxxx.com; # change to match your URL
location / {
# match the name of upstream directive which is defined above
proxy_pass http://ss_api;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache cloud;
proxy_cache_valid 200 302 60m;
proxy_cache_valid 404 …Run Code Online (Sandbox Code Playgroud) 我被要求建立一个网站,其中一位联合开发人员告诉我,我需要包含keep-alive标头.
好吧,我读了很多关于它,但我仍有疑问.
当客户端对网页内容发出多个请求时,打开连接可提高性能,因为服务器可以更快地返回每个请求的内容.否则,服务器必须为每个请求打开一个新连接
看着

keep alive头(或用户发送保活),岂不是(E,C,B)保存这仅仅是我的会话的连接?对于那些感兴趣的人:
单击此示例页面将返回keep alive标头
我需要保持nginx和上游nodejs之间的连接.
刚刚编译并安装了nginx 1.2.0
我的配置文件:
upstream backend {
ip_hash;
server dev:3001;
server dev:3002;
server dev:3003;
server dev:3004;
keepalive 128;
}
server {
listen 9000;
server_name dev;
location / {
proxy_pass http://backend;
error_page 404 = 404.png;
}
}
Run Code Online (Sandbox Code Playgroud)
我的程序(dev:3001 - 3004)在响应后检测到连接被nginx关闭.
我们部署了一个Express Web API,它在通过NGINX代理的EC2 ubuntu服务器上运行时获得了相当少的流量(平均每秒约10个请求).每隔一段时间,一个请求就会挂起,如果客户端等待的时间足够长,则会将包含以下内容的行输出到NGINX错误日志:
upstream timed out (110: Connection timed out) while connecting to upstream
Run Code Online (Sandbox Code Playgroud)
我已经在这里尝试了建议的解决方案,但似乎没有效果.这只发生在我们每分钟1-3次的知识上,但我只是关闭这些日志.如果客户端在请求超时之前刷新其页面或导航,则似乎没有记录.
错误消息显然表明连接到上游服务器有什么问题,但为什么这种情况很少发生?导致此问题的URL中绝对没有模式,并且我所知道的代理应用程序仍然可用.这是我们NGINX配置的概念:
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 10000;
}
worker_rlimit_nofile 25000;
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
client_max_body_size 15M;
include /etc/nginx/mime.types;
include /etc/nginx/conf.d/ *.conf; //Added space before star because so formatting was turning it into a comment
include /etc/nginx/sites-enabled/ *;
default_type application/octet-stream;
log_format nginx_json '{ "timestamp": "$time_local", '
' "request_ip": "$remote_addr", …Run Code Online (Sandbox Code Playgroud) 我使用 PHP 和 Apache 以及 nginx 进行反向代理,全部都在 Docker 上,并且我有几个长时间运行的调用,这些调用在 60 秒后计时,导致 504 网关超时。我知道我的应用程序被成功调用,因为我正在跟踪 PHP 应用程序的日志,并且我可以看到它正在积极写入日志。每次都是 60 秒超时,但我似乎无法弄清楚该设置在哪里。
我尝试了这篇文章中的建议,但没有任何效果。我已经用一些与时间相关的设置更新了我的 php.ini 文件,并且我已经验证它们是使用 phpinfo 设置的
max_input_time = 0
max_execution_time = 500
Run Code Online (Sandbox Code Playgroud)
我还将内存限制增加到 512,但考虑到每次都会在大约 60 秒内超时,我认为这不是问题。
至于更新 nginx 设置,我最初按照本教程调整 nginx-proxy 超时,但这不起作用。我取消了更改,然后 ssh 进入容器并手动更新 /etc/nginx/nginx.conf,http 部分如下所示
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 500;
proxy_connect_timeout 600;
proxy_send_timeout 600;
send_timeout 600;
client_max_body_size …Run Code Online (Sandbox Code Playgroud) nginx ×4
http ×2
amazon-ec2 ×1
apache ×1
docker ×1
express ×1
http-headers ×1
keep-alive ×1
node.js ×1
php ×1
puma ×1
timeout ×1