首页 > 其他 > 详细

98.nginx 的设置timeout

时间:2020-09-29 10:28:56      阅读:34      评论:0      收藏:0      [点我收藏+]

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

98.nginx 的设置timeout

原文:https://www.cnblogs.com/liuzhanghao/p/13748318.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!