文章来源:nginx send_timeout 超时导致的302 错误

1. send_timeout

syntax: send_timeout the time

default: send_timeout 60

context: http, server, location

Directive assigns response timeout to client. Timeout is established not on entire transfer of answer, but only between two operations of reading, if after this time client will take nothing, then nginx is shutting down the connection.

注意fastcgi_connect_timeout fastcgi_read_timeout fastcgi_send_timeout 类似

proxy_connect_timeout 65s; #连接超时 默认为60秒
proxy_read_timeout 65s; #读取超时 默认为60秒
proxy_send_timeout 65s; #发送超时 默认为60秒

Syntax: proxy_connect_timeout time;
Default: proxy_connect_timeout 60s;
Context: http, server, location 
Defines a timeout for establishing a connection with a proxied server. It should be noted that this timeout cannot usually exceed 75 seconds.
定义用于建立与代理服务器的连接超时。应当注意的是,此超时通常不能超过75秒。

Syntax: proxy_read_timeout time;
Default: proxy_read_timeout 60s;
Context: http, server, location
Defines a timeout for reading a response from the proxied server. The timeout is set only between two successive read operations, not for the transmission of the whole response. If the proxied server does not transmit anything within this time, the connection is closed.
定义了从代理服务器读取响应超时。只是在两个连续的读取操作之间设置超时,而不是为整个响应的传输设置超时时间。如果代理服务器在这段时间内不发送任何东西,连接关闭。

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比较强大,可以针对单个域名请求做出单个连接超时的配置.

比如些动态解释和静态解释可以根据业务的需求配置

proxy_connect_timeout :后端服务器连接的超时时间_发起握手等候响应超时时间

proxy_read_timeout:连接成功后_等候后端服务器响应时间_其实已经进入后端的排队之中等候处理(也可以说是后端服务器处理请求的时间)

proxy_send_timeout :后端服务器数据回传时间_就是在规定时间之内后端服务器必须传完所有的数据

server
  {
 listen       80;
 server_name www.qq.cn;
 index index.jsp index.do index.html;
 root  /data/webapp/qqroot;

#limit_conn   crawler  20;

location /(WEB-INF)/ {
  deny all;
 }

location / {
  proxy_pass http://192.168.1.31:8081;
  proxy_connect_timeout 500s;
  proxy_read_timeout 500s;
  proxy_send_timeout 500s;
  proxy_set_header        X-Real-IP $remote_addr;
  proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header        Host $http_host;
 }

location ~* (\.jpg)|(\.gif)|(\.png)|(\.swf)|(\.html)|(\.htm)|(\.exe)|(\.flv)|(\.doc)|(\.rar)|(\.rtf)|(\.bmp)|(\.xls)$
 {
  root /data/webapp/qqroot/;
 }

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
 {
  expires      30d;
 }

}

proxy_connect_timeout

语法: proxy_connect_timeout timeout_in_seconds

上下文: http, server, location

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 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 the_time

默认值: proxy_read_timeout 60

上下文: 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 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 proxyserver 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_in_seconds

默认值: proxy_send_timeout 60

上下文: http, server, location

This directive assigns timeout with the transfer of request to the proxy server. Time out is established not on entire transfer of request, but only between two operations of record. If after this time the proxy server will not take new data, then nginx is shut the connection

proxy_connect_timeout、proxy_read_timeout、proxy_send_timeout

proxy_connect_timeout  是和后端建立连接的超时时间,记住不要超过 75s 。如果超时,Nginx 的返回码是多少? 504

proxy_read_timeout  是从后端读取数据的超时时间,两次读取操作的时间间隔如果大于这个值,和后端的连接会被关闭。如果一个请求时间时间非常大,要把这个值设大点。如果超时,Nginx 的返回码是多少? 504

proxy_send_timeout  是向后端写数据的超时时间,两次写操作的时间间隔大于这个值,也就是过了这么长时间后端还是没有收到数据(我理解是 根据 TCP ACK 判断),连接会被关闭。如果超时,Nginx 的返回码是多少? 504

nginx 的proxy 时间讲解相关推荐

  1. Nginx的启动阶段讲解

    Nginx的启动阶段讲解 概述 nginx启动阶段指从nginx初始化直至准备好按最新配置提供服务的过程. 在不考虑nginx单进程工作的情况下,这个过程包含三种方式: 启动新的nginx reloa ...

  2. nginx反向代理原理讲解

    一 .概述                  反向代理(Reverse Proxy)方式是指以代理服务器来接受Internet上的连接请求,然后将请求转发给内部网络上的服务器:并将从服务器上得到的结果 ...

  3. 搞懂nginx的proxy模块-01

    搞懂nginx的proxy模块-01 nginx的ngx_http_proxy_module模块的指令着实是太多了,其实平时工作中经常用到的指令也就是那几个,但是如果不细看下文档的话,下次对一些配置的 ...

  4. nginx设置缓存时间

    nginx设置缓存时间 前置知识 设置expires 生效修改 由于nginx的默认缓存时间为0,如果在页面中将诸如视频,音乐等容量较大的元素作为页面背景,当用户重复访问本网站时,会从服务器端重复下载 ...

  5. Nginx/Openresty日志时间显示到毫秒级的三种方法(不改源码)

    Nginx/Openresty日志时间显示到毫秒级的三种方法(不改源码) 方法一 :set (只能在server节点内) 方法二: set_by_lua (只能在server节点内) 方法三: map ...

  6. nginx依靠超时时间实现上游负载web服务器重启时不影响访问

    nginx依靠超时时间实现上游负载web服务器重启时不影响访问 本文未配置主从机集群,主从多台集群. nginx.conf(或者外联配置文件)中,位于http{}之内,样例如下: - upstream ...

  7. nginx设置超时时间

    nginx设置超时时间 server模块下                 proxy_connect_timeout  360000s;#nginx跟后端服务器连接超时时间(代理连接超时)     ...

  8. 配置nginx网页缓存时间

    配置nginx网页缓存时间 当Nginx将网页数据返回给客户端后,可设置资源在客户端缓存的时间,以方便客户端在日后进行相同内容的请求时直接返回,以避免重复请求,加快了访问速度,一般针对静态网页进行设置 ...

  9. nginx 反向proxy多个 tomcat,负载均衡

    负载均衡 一,正向proxy与反向proxynginx 二,nginx安装 三,nginx负载均衡 场景 四,配置nginx访问代理多个tomcat 一,正向proxy与反向proxynginx 正向 ...

  10. nginx配置文件解析加讲解

    nginx配置文件解析 nginx的组成部分(初始配置) nginx主要配置文件优化 日志优化 nginx监控 控制访问权限 列出linux中的列表 设置文件缓存 设置请求限制 设置IP高并发(限制多 ...

最新文章

  1. 互联网周刊2021云办公平台TOP50,leangoo领歌敏捷研发协作入选
  2. android 6.0 sd卡读写权限,Android 6.0 读写SD卡权限问题
  3. ubuntu 安装 php
  4. cpta 好像有漏洞
  5. wince6下usb摄像头(UVC)使用指南
  6. 关于iOS7里的JavaScriptCore framework
  7. python 数据结构与算法
  8. Python读取Excel文件统计演员参演电影
  9. 厉精图治的拼音及解释
  10. 【入门篇】黑盒测试基础
  11. TCP连接关闭—close和shutdown
  12. 永洪报表工具_表格软件下载排行榜Top7
  13. matlab里怎么计算期望,§7.4.2 利用MATLAB计算随机变量的期望和方差.pdf
  14. 认知计算机系统和应用实验报告,计算机认知实习课实验报告.doc
  15. CATIA Automation 编程初探
  16. jQuery实现购物车
  17. Ntrip协议访问千寻位置服务
  18. 控件 UIView UILabel UITextField UITextView UIButton ;的字体、大小、单位、颜色
  19. 使用easyExcel批量导入导出数据
  20. php cgi远程控制,php cgi远程任意代码执行漏洞

热门文章

  1. 字蛛font-spider报错 web font not found
  2. 【网安入门】学习笔记(一)
  3. Thinkphp 5.0 仿百度糯米开发多商家电商平台
  4. <aop:aspectj-autoproxy />AOP自动代理
  5. OpenSSL源码下载及编译
  6. Spring Boot网上图书商城
  7. MATLAB的基本用法
  8. 理论估计电池寿命(来自TI蓝牙智能锁案例)
  9. UE4Possess切换控制Pawn
  10. 改变指标改变图(FusionChart)