php-fpm 配置不当 导致 nginx 502 错误一例

jackxiang 2014-10-1 00:07 | |
背景:开php-fpm的9000端口,有时配置出错会出现502,特别转载。
不要总看nginx 的日志文件。
对于开端口这种事情,listen.allowed_clients 里逗号分割不能有空格!
[www]
listen = 10.11.80.49:9000
listen.allowed_clients = 10.11.80.47,10.11.80.48, 10.11.80.49


cat /home/php/logs/php-fpm.log 部分内容如下

"Error: Wrong IP address ' 10.11.80.49' in listen.allowed_clients"
"Error: Connection disallowed: IP address '10.11.80.49' has been dropped."

ERROR: Connection disallowed: IP address "10.11.80.49" has been dropped

回头且看php-fpm 配置文件
cat /home/php/etc/php-fpm.conf

[global]
pid = /home/php/logs/php-fpm.pid
error_log = /home/php/logs/php-fpm.log
log_level = notice

[www]
listen = 10.11.80.49:9000
listen.allowed_clients = 10.11.80.47,10.11.80.48, 10.11.80.49
user = nobody
group = nobody

slowlog = /home/php/logs/slow.log
catch_workers_output = yes
request_terminate_timeout = 30s
request_slowlog_timeout = 5s

pm = dynamic
pm.max_children = 100
pm.start_servers = 50
pm.min_spare_servers = 5
pm.max_spare_servers = 100

就是这里

[www]
listen = 10.11.80.49:9000
listen.allowed_clients = 10.11.80.47,10.11.80.48, 10.11.80.49
user = nobody
group = nobody

netstat 看到的端口是listen 状态,启动php-fpm 无报错。
其它两台机器 47 48 也没有问题,我就奇怪了,telnet 一下测试

#telnet 10.11.80.49 9000
Tring 10.11.80.49 ...
Connected to 10.11.80.49
Esape character is '^]'.

我分别在47 和48 上测试, 发现不一样的就是 49 是被直接close 掉的。
后面再看配置文件,48 后面多了一个空格。去掉重启,测试,我勒个去。

来自:http://adslroot.blogspot.com/2014/02/php-fpm-nginx-502.html

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:http://jackxiang.com/post/7538/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!


最后编辑: jackxiang 编辑于2014-10-1 00:08
评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]