proxy_read_timeout
proxy模块的proxy_read_timeout
syntax: proxy_read_timeout the_time
default: proxy_read_timeout 60
context: http, server, location
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_read_timeout 要设置超过这个时间,否则出现504状态码(网关错误)。proxy_read_timeout设置大一点即可,再有一点就是,这个时间设置,并不是整个响应周期的时间,有些响应分好几次传输,该时间就是两次成功传输间的时间。
当请求大文件时,后端生成资源比较慢的状态下,就直接更改该选项即可。
proxy_send_timeout time
Syntax: proxy_send_timeout time;
Default: proxy_send_timeout 60s;
Context: http, server, location
Sets a timeout for transmitting a request to the proxied server. The timeout is set only between two successive write operations, not for the transmission of the whole request. If the proxied server does not receive anything within this time, the connection is closed.
这是nginx代理服务器向后端服务发起请求的超时时间,请求比较大时,会依次发送,在规定的时间内,服务端没有收到任何请求,那么连接就会关闭。
underscores_in_headers on
nginx代理默认会把header中参数的 "_" 下划线去掉,所以后台服务器后就获取不到带"_"线的参数名。
underscores_in_headers on;
#该属性默认为off,表示如果header name中包含下划线,则忽略掉。请求头如果有下划线,我们将该选项设置为on即可。