98.nginx 的设置timeout

nginx常用的超时间

# fail_timeout 参数
 upstream  netitcast.com {  #服务器集群名字   
        server    192.168.88.103:8080  weight=2 max_fails=2 fail_timeout=20s;  #tomcat1
        server    192.168.88.103:8082  weight=2 max_fails=2 fail_timeout=20s;  #tomcat2
         server    192.168.88.103:8084  backup ;    #tomcat3
    }
location / {  
            proxy_pass http://netitcast.com;  
            proxy_redirect default;  
            proxy_connect_timeout 10;  
        }  
proxy_connect_timeout   -- 发送请求建立连接的超时间
fail_timeout  -- 当发送向这个服务器的请求失败数max_fails达到设置的数字时,多少秒内不再向这个服
务器发送请求

# 连接保持时长
keepalive_timeout  -- 配置段: http, server, location  keepalive_timeout 60s;

# 指定客户端与服务端建立连接后发送 request body 的超时时间。如果客户端在指定时间内没有发送任何
内容,Nginx 返回 HTTP 408(Request Timed Out)
client_body_timeout  -- 配置段: http, server, location   client_body_timeout 20s;

# 客户端向服务端发送一个完整的 request header 的超时时间。如果客户端在指定时间内没有发送一个完
整的 request header,Nginx 返回 HTTP 408(Request Timed Out)。
client_header_timeout  -- 配置段: http, server, location client_header_timeout 10s;

# 服务端向客户端传输数据的超时时间,根据转发的应用服务可以配置 proxy_send_timeout、
uwsgi_send_timeout、fastcgi_send_timeout
send_timeout -- 配置段:http, server, location   send_timeout 60s;

# nginx 与 upstream server 的连接超时时间,默认为 60s;根据应用不同可配置 
uwsgi_send_timeout/fascgi_send_timeout/proxy_send_timeout
proxy_connect_timeout  -- Context: http, server, location   proxy_connect_timeout 60s;

# nginx接收upstream serve 数据超时,默认60s,如果连续的60s内没有收到1个字节,连接关闭;
根据应用不同可配置 uwsgi_send_timeout/fascgi_send_timeout/proxy_send_timeout,
理解为服务端向nginx相应数据的超时时间(三次握手已经建立,但是无数据返回)
proxy_read_timeout  -- Context: http, server, location   proxy_read_timeout 60s;

# nginx 发送数据至upstream server超时默认60s,如果连续的60s内没有发送1个字节
连接关闭;根据应用不同可配置 uwsgi_send_timeout/fascgi_send_timeout/proxy_send_timeout,
理解为服务端向nginx返回数据的超时时间(三次握手已经建立,但是数据必须在这个设置好的时间段内全部返回,否则超时不予处理)
proxy_send_timeout -- Context: http, server, location  proxy_send_timeout 60s;

# 域名解析超时,默认 30s
resolver_timeout  -- Context: http, server, location   resolver_timeout 30s;

# 在关闭连接前,会检测是否有用户发送的数据到达服务器,如果超过lingering_timeout时间
后还没有数据可读,就直接关闭连接;否则,必须在读取完连接缓冲区上的数据并丢弃掉后才会关闭连接。
lingering_timeout  -- Context: http, server, location  ingering_timeout 5s;

参考 
	https://www.cnblogs.com/lemon-flm/p/8352194.html
	http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout
	https://blog.csdn.net/zhuyu19911016520/article/details/90714429
原文地址:https://www.cnblogs.com/liuzhanghao/p/13748318.html