Nginx常见的错误说明

400 bad request

配置nginx.conf相关设置如下.

client_header_buffer_size 16k;
large_client_header_buffers 4 64k;

根据具体情况调整,一般适当调整值就可以。

413 Request Entity Too Large错误

这个错误一般在上传文件的时候会出现,

编辑Nginx主配置文件Nginx.conf,找到http{}段,添加

client_max_body_size 10m; //设置多大根据自己的需求作调整.
如果运行php的话这个大小client_max_body_size要和php.ini中的如下值的最大值一致或

者稍大,这样就不会因为提交数据大小不一致出现的错误。

post_max_size = 10M
upload_max_filesize = 2M

502 Bad Gateway错误

在php.ini和php-fpm.conf中分别有这样两个配置项:max_execution_time和request_terminate_timeout。

还有一种是设置了代理或负载均衡的的,后端获取不到数据也会出现502 比如php-fpm 没启动  ,web服务器出现问题

 

504 Gateway Time-out(nginx)

默认的fastcgi进程响应的缓冲区是8K, 我们可以设置大点在nginx.conf里,加入:

fastcgi_buffers 8 128k #表示设置fastcgi缓冲区为8×128
当然如果您在进行某一项即时的操作,可能需要nginx的超时参数调大点,例如设置成90秒:
send_timeout 90;
只是调整了这两个参数,结果就是没有再显示那个超时,效果不错.

Nginx中关于与上游服务器通信超时时间的配置factcgi_connect/read/send_timeout。

要注意的是factcgi_connect/read/send_timeout是对FastCGI生效的,而proxy_connect/read/send_timeout是对proxy_pass生效的。

还有很多是程序本身有异常执行超时,比如连接第三方api接口等一直连接不上

 

 

错误信息 错误说明

“upstream prematurely(过早的) closed connection”

请求uri的时候出现的异常,是由于upstream还未返回应答给用户时用户断掉连接造成的,对系统没有影响,可以忽略
“recv() failed (104: Connection reset by peer)”
(1)服务器的并发连接数超过了其承载量,服务器会将其中一些连接Down掉;

(2)客户关掉了浏览器,而服务器还在给客户端发送数据;

(3)浏览器端按了Stop

 

“(111: Connection refused) while connecting to upstream”

用户在连接时,若遇到后端upstream挂掉或者不通,会收到该错误

“(111: Connection refused) while reading response header from upstream”

用户在连接成功后读取数据时,若遇到后端upstream挂掉或者不通,会收到该错误

“(111: Connection refused) while sending request to upstream”

Nginx和upstream连接成功后发送数据时,若遇到后端upstream挂掉或者不通,会收到该错误

“(110: Connection timed out) while connecting to upstream”

nginx连接后面的upstream时超时

“(110: Connection timed out) while reading upstream”
nginx读取来自upstream的响应时超时

 

“(110: Connection timed out) while reading response header from upstream”

nginx读取来自upstream的响应头时超时

“(110: Connection timed out) while reading upstream”

nginx读取来自upstream的响应时超时

“(104: Connection reset by peer) while connecting to upstream” upstream

发送了RST,将连接重置

“upstream sent invalid header while reading response header from upstream”

upstream发送的响应头无效

“upstream sent no valid HTTP/1.0 header while reading response header from upstream”

upstream发送的响应头无效

“client intended to send too large body”

用于设置允许接受的客户端请求内容的最大值,默认值是1M,client发送的body超过了设置值

“reopening logs” 用户发送kill  -USR1命令
“gracefully shutting down”, 用户发送kill  -WINCH命令
“no servers are inside upstream” upstream下未配置server
“no live upstreams while connecting to upstream” upstream下的server全都挂了
“SSL_do_handshake() failed” SSL握手失败
“ngx_slab_alloc() failed: no memory in SSL session shared cache” ssl_session_cache大小不够等原因造成
“could not add new SSL session to the session cache while SSL handshaking” ssl_session_cache大小不够等原因造成

About sun 83 Articles
85后青年,自诩为伪文艺青年

Be the first to comment

回复 匿名 取消回复

Your email address will not be published.


*