HTTP状态码 502和504区别详解
2017-03-29 00:00
183 查看
1.状态码的RFC说明
502:Bad GatewayThe server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.
作为网关或者代理工作的服务器尝试执行请求时,从上游服务器接收到无效的响应
504:Gateway Time-out
The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request.
Note: Note to implementors: some deployed proxies are known to return 400 or 500 when DNS lookups time out.
作为网关或者代理工作的服务器尝试执行请求时,未能及时从上游服务器(URI标识出的服务器,例如HTTP、FTP、LDAP)或者辅助服务器(例如DNS)收到响应。
2.具体原因分析
nginx返回502,是收到了服务理解的相应1. nginx和php-fpm无法连接
2. nginx和php-fpm的链接被异常的断开
以下的分析通过nginx+php-fpm来进行分析,其他的工具也可以进行类似分析
php的配置文件: http://php.net/max-execution-time max_execution_time integer
这设置了脚本被解析器中止之前允许的最大执行时间,单位秒。 这有助于防止写得不好的脚本占尽服务器资源。 默认设置为 30。 从命令行运行 PHP 时,默认设置为 0。
最大执行时间不会影响系统调用和系统操作,更多细节查看:set_time_limit
http://php.net/manual/zh/function.set-time-limit.php
bool set_time_limit( int $seconds )
设置脚本可以运行的时间,单位是秒。如果超过了该设置,脚本会返回一个致命的错误。
set_time_limit()函数和配置指令max_execution_time只是影响脚本本身执行的时间,任何发生在如使用system()的系统调用,刘
操作,数据库操作等的脚本执行的最大时间是不包含在其中的。
php-fpm.conf文件:
request_terminate_timeout
3.实践测试
测试1:启动nginx,不启动php-fpm现象:nginx服务器返回502
说明:nginx无法连接php-fpm,在达到nginx最大的超时时间的时候,nginx还没有获取到响应就会返回502
测试2:启动nginx,启动php-fpm
相关文章推荐
- HTTP状态码详解 404 500 502 504... 全解
- 服务器错误码500 501 502 503 504 505 详解
- Nginx 中 502 和 504 错误详解
- 新手指导贴一 最新热门裤型对比 图文并茂 对比501 502 504 505等裤型区别 LEVIS
- 服务器错误500 501 502 503 504 505 详解
- 服务器错误500 501 502 503 504 505 详解
- 服务器错误500 501 502 503 504 505 详解
- Nginx 中 502 和 504 错误详解
- div+css中id和class的区别运用详解
- 二层、三层、四层交换机的区别详解
- [转]Bind和Eval的区别详解
- Web服务器和应用程序服务器区别详解
- .net/c#中栈和堆的区别及代码在栈和堆中的执行流程详解之一
- 交换机中的堆叠与级连区别详解
- 无线路由、AP、网桥之区别详解篇
- [转]Bind和Eval的区别详解
- Bind和Eval的区别详解(ZT)
- df 和du 的区别 linux磁盘命令详解
- 17个之多!Windows Vista各版本功能区别详解