1、文件大小超过限制

错误信息:413 request Entity Too Large

错误截图:

高并发nginx代理连接超时(nginx上传文件超过限制大小)(1)

相关配置:

client_max_body_size:

Syntax:

client_max_body_size size;

Default:

client_max_body_size 1m;

Context:

http, server, location

Sets the maximum allowed size of the client request body, specified in the “Content-Length” request header field. If the size in a request exceeds the configured value, the 413 (Request Entity Too Large) error is returned to the client. Please be aware that browsers cannot correctly display this error. Setting size to 0 disables checking of client request body size.

翻译:设置客户端请求正文的最大允许大小,在“Content-Length”请求头部字段中指定。如果请求中的大小超过配置的值,则向客户端返回413(请求实体太大)错误。请注意,浏览器无法正确显示此错误。将SIZE设置为0将禁用客户端请求正文大小检查。

出处:http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size

2、连接超时

错误信息:504 Gateway Time-out

错误截图:

相关配置:

proxy_read_timeout:

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.

翻译:定义从代理服务器读取响应的超时时间。超时仅在两个连续的读取操作之间设置,而不是针对整个响应的传输。如果代理服务器在此时间内没有传输任何内容,则连接将关闭。

出处:http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout

注意:一般的请求超时多数都是后端代码业务处理耗时较长导致,故修改这个配置较多,搞不定再修改下面三个配置

fastcgi_connect_timeout:

Syntax:

fastcgi_connect_timeout time;

Default:

fastcgi_connect_timeout 60s;

Context:

http, server, location

Defines a timeout for establishing a connection with a FastCGI server. It should be noted that this timeout cannot usually exceed 75 seconds.

翻译:定义与FastCGI服务器建立连接的超时时间。应该注意,此超时通常不能超过75秒。

出处:http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_connect_timeout

fastcgi_send_timeout:

Syntax:

fastcgi_send_timeout time;

Default:

fastcgi_send_timeout 60s;

Context:

http, server, location

Sets a timeout for transmitting a request to the FastCGI server. The timeout is set only between two successive write operations, not for the transmission of the whole request. If the FastCGI server does not receive anything within this time, the connection is closed.

翻译:设置向FastCGI服务器传输请求的超时时间。超时仅在两个连续的写入操作之间设置,而不是针对整个请求的传输。如果FastCGI服务器在此时间内未收到任何内容,则连接将关闭。

出处:http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_send_timeout

fastcgi_read_timeout:

Syntax:

fastcgi_read_timeout time;

Default:

fastcgi_read_timeout 60s;

Context:

http, server, location

Defines a timeout for reading a response from the FastCGI server. The timeout is set only between two successive read operations, not for the transmission of the whole response. If the FastCGI server does not transmit anything within this time, the connection is closed.

翻译:定义从FastCGI服务器读取响应的超时时间。超时仅在两个连续的读取操作之间设置,而不是针对整个响应的传输。如果FastCGI服务器在此时间内没有传输任何内容,则连接将关闭。

出处:http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_read_timeout

,