nginx 转发请求超时

来源:互联网 发布:淘宝汽车超人假机油 编辑:程序博客网 时间:2024/05/20 18:19


修改nginx 配置文件/etc/nginx/nginx.conf

添加:

        proxy_connect_timeout 300;        proxy_send_timeout 300;        proxy_read_timeout 300;        keepalive_timeout  300;        fastcgi_connect_timeout 6000;        fastcgi_send_timeout 6000;        fastcgi_read_timeout 6000;        fastcgi_buffer_size 256k;        fastcgi_buffers 8 256k;        fastcgi_busy_buffers_size 256k;        fastcgi_temp_file_write_size 256k;

重启nginx服务再次运行 问题解决


proxy转发模块的超时设置:proxy_connect_timeout语法 proxy_connect_timeout time 默认值 60s上下文 http server location说明 该指令设置与upstream server的连接超时时间,有必要记住,这个超时不能超过75秒。这个不是等待后端返回页面的时间,那是由proxy_read_timeout声明的。如果你的upstream服务器起来了,但是hanging住了(例如,没有足够的线程处理请求,所以把你的请求放到请求池里稍后处理),那么这个声明是没有用的,因为与upstream服务器的连接已经建立了。This directive assigns a timeout for the connection to the proxyserver. This is not the time until the server returns the pages, this is the proxy_read_timeout statement. If your proxyserver is up, but hanging (e.g. it does not have enough threads to process your request so it puts you in the pool of connections to deal with later), then this statement will not help as the connection to the server has been made. It is necessary to keep in mind that this time out cannot be more than 75 seconds.proxy_read_timeout语法 proxy_read_timeout time 默认值 60s上下文 http server location说明 该指令设置与代理服务器的读超时时间。它决定了nginx会等待多长时间来获得请求的响应。这个时间不是获得整个response的时间,而是两次reading操作的时间。(??什么是两次reading操作的时间)This directive sets the read timeout for the response of the proxied server. It determines how long NGINX will wait to get the response to a request. The timeout is established not for entire response, but only between two operations of reading.In contrast to proxy_connect_timeout, this timeout will catch a server that puts you in it's connection pool but does not respond to you with anything beyond that. Be careful though not to set this too low, as your proxy server might take a longer time to respond to requests on purpose (e.g. when serving you a report page that takes some time to compute). You are able though to have a different setting per location, which enables you to have a higher proxy_read_timeout for the report page's location.If the proxied server nothing will communicate after this time, then nginx is shut connection.proxy_send_timeout语法 proxy_send_timeout time 默认值 60s上下文 http server location说明 这个指定设置了发送请求给upstream服务器的超时时间。超时设置不是为了整个发送期间,而是在两次write操作期间。如果超时后,upstream没有收到新的数据,nginx会关闭连接


原创粉丝点击