4xx系统


404 Not found 资源不存在 如

403 Forbiden 禁止  权限不允许或者访问的目录没权限或者目录中index页面不存在


499: 这个要关注了特别是nginx

499, client has closed connection

代表客户端主动断开了连接,一般是服务端处理时间太长了,客户端等不了就断开了主动断开关闭浏览器。还有一种情况就是有人***,故意消耗服务端资源。

在nginx源码中,499对应的定义是 “client has closed connection”。这很有可能是因为服务器端处理的时间过长,客户端“不耐烦”了。要解决此问题,就需要在程序上面做些优化了。


499这个状态码并不是http协议中定义的status code,而是nginx自己定义的一个状态码。
当客户端主动断开连接的时候,nginx就会返回499的状态码。一般情况下和请求的超时设置有关系,比如用户用浏览器访问某个网页的时候,如果在nginx还没有处理完请求的时候,用户就关闭了网页活着浏览器,则这个时候,nginx就会以499的状态码进行影响,标明客户端主动断开了连接。


5xx系列


500

内部服务错误Internal Server Error

原因一般是: 访问量大,服务器资源吃不消,或者内部执行错误,如后端mysql挂了。


如:memory allocation failure

502(同 504情况差不多)

Bad Gateway 

原因一般是:

nginx出现502有很多原因,但大部分原因可以归结为资源数量不够用,也就是说后端php-fpm处理有问题,nginx将正确的客户端请求发给了后端的php-fpm进程,但是因为php-fpm进程的问题导致不能正确解析php代码,最终返回给了客户端502错误


2 php-fpm 挂了


503

Service Temporarily Unavailable

原因一般是:

1 访问并发数过多

2 nginx做了并发数限制,同一个IP访问操作限制

limit_conn one 1;



504

Gateway time-out 网关超时

原因:

1 nginx worker数目是否够用

ps -ef |grep php-fpm |wc -l 减去2


fastcig缓冲(buffer)或者是代理的缓存情况,如果缓存过小,设置时间短,机器又繁忙,机会出现502的情况


3 php执行时间长,而设置的超时时间又短 相关指令

fastcgi_connect_timeout 60;

fastcgi_send_timeout 60;

fastcgi_read_timeout 60;



502一般与php-fpm.conf有关,504一般和nginx的nginx.conf配置有关,都有可能是和nginx和后端有关。






【附件-code表格】

Table 13-1. HTTP response status codes

CodeReason phraseRFC 2616 section
0No Response Received (Squid-specific)N/A
1xxInformational10.1
100Continue10.1.1
101Switching Protocols10.1.2
2xxSuccessful10.2
200OK10.2.1
201Created10.2.2
202Accepted10.2.3
203Non-Authoritative Information10.2.4
204No Content10.2.5
205Reset Content10.2.6
206Partial Content10.2.7
3xxRedirection10.3
300Multiple Choices10.3.1
301Moved Permanently10.3.2
302Found10.3.3
303See Other10.3.4
304Not Modified10.3.5
305Use Proxy10.3.6
306(Unused)10.3.7
307Temporary Redirect10.3.8
4xxClient Error10.4
400Bad Request10.4.1
401Unauthorized10.4.2
402Payment Required10.4.3
403Forbidden10.4.4
404Not Found10.4.5
405Method Not Allowed10.4.6
406Not Acceptable10.4.7
407Proxy Authentication Required10.4.8
408Request Timeout10.4.9
409Conflict10.4.10
410Gone10.4.11
411Length Required10.4.12
412Precondition Failed10.4.13
413Request Entity Too Large10.4.14
414Request-URI Too Long10.4.15
415Unsupported Media Type10.4.16
416Requested Range Not Satisfiable10.4.17
417Expectation Failed10.4.18
5xxServer Error10.5
500Internal Server Error10.5.1
501Not Implemented10.5.2
502Bad Gateway10.5.3
503Service Unavailable10.5.4
504Gateway Timeout10.5.5
505HTTP Version Not Supported10.5.6
6xxProxy ErrorN/A
600Unparseable Response Headers (Squid-specific)N/A


假如Squid从原始服务器没有接受到任何响应,你可在access.log里看到状态码0。假如Squid接受到的响应没有包含HTTP头部,就会出现状态码600。在少数情况下,某些原始服务器仅发送响应body,而忽略了任何头部。