且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

http code 返回码

更新时间:2022-09-30 20:37:41


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

Code Reason phrase RFC 2616 section
0 No Response Received (Squid-specific) N/A
1xx Informational 10.1
100 Continue 10.1.1
101 Switching Protocols 10.1.2
2xx Successful 10.2
200 OK 10.2.1
201 Created 10.2.2
202 Accepted 10.2.3
203 Non-Authoritative Information 10.2.4
204 No Content 10.2.5
205 Reset Content 10.2.6
206 Partial Content 10.2.7
3xx Redirection 10.3
300 Multiple Choices 10.3.1
301 Moved Permanently 10.3.2
302 Found 10.3.3
303 See Other 10.3.4
304 Not Modified 10.3.5
305 Use Proxy 10.3.6
306 (Unused) 10.3.7
307 Temporary Redirect 10.3.8
4xx Client Error 10.4
400 Bad Request 10.4.1
401 Unauthorized 10.4.2
402 Payment Required 10.4.3
403 Forbidden 10.4.4
404 Not Found 10.4.5
405 Method Not Allowed 10.4.6
406 Not Acceptable 10.4.7
407 Proxy Authentication Required 10.4.8
408 Request Timeout 10.4.9
409 Conflict 10.4.10
410 Gone 10.4.11
411 Length Required 10.4.12
412 Precondition Failed 10.4.13
413 Request Entity Too Large 10.4.14
414 Request-URI Too Long 10.4.15
415 Unsupported Media Type 10.4.16
416 Requested Range Not Satisfiable 10.4.17
417 Expectation Failed 10.4.18
5xx Server Error 10.5
500 Internal Server Error 10.5.1
501 Not Implemented 10.5.2
502 Bad Gateway 10.5.3
503 Service Unavailable 10.5.4
504 Gateway Timeout 10.5.5
505 HTTP Version Not Supported 10.5.6
6xx Proxy Error N/A
600 Unparseable Response Headers (Squid-specific) N/A


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

本文转自残剑博客51CTO博客,原文链接http://blog.51cto.com/cuidehua/1829225如需转载请自行联系原作者

cuizhiliang