产品服务AMH 免费服务器主机面板SSL证书 免费SSL证书申请 担保单 免费安全、零费率交易平台编程助手免费智能写代码、翻译AMYSQL 免费MySQL管理工具

AMH 社区首页

 AMH社区 - 开放自由有价值的社区

[求助帖] 域名正常运行一段时间后会 400 bad request

chen_off
铁牌会员
24.00 价值分

chen_off 发表于 2015-04-25 18:05:56
本帖最后由 chen_off 于 2015-4-25 19:28 编辑

域名正常运行一段时间后会 400 bad request PHP文件无法执行,静态文件可以访问,然后执行php重启就恢复正常。过一段时间又这样。
amh4.2 版本。
服务器128G内存,24核。


虚拟主机PHP-FPM 当前设置为动态1,50,300,300
(静态和ondemand 都设置过

-------------------------
http://amh.sh/bbs/post-669-1-1.htm
用这个方法试过不行。
-------------------------
memory_limit 设置10240M 也不行
-------------------------
设置过计划任务重启PHP 和 nginx 也不行。

服务器的负载主要是外部访问和自己访问自己,执行PHP文件。

同服务器中的其他域名都正常。负载主要是来自会自动400 bad request 的那个域名。

nginx 测试结果
# /usr/local/nginx/sbin/nginx -t
nginx: [emerg] directive "rewrite" is not terminated by ";" in /usr/local/nginx/conf/rewrite/phpcms.conf:7
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

下面是重启Nginx的结果
=============================================================
[LNMP/Nginx] Amysql Host - AMH 4.2
http://Amysql.com

[OK] Nginx stop
=============================================================
[LNMP/Nginx] Amysql Host - AMH 4.2
http://Amysql.com

Shutting down MySQL... SUCCESS!
[OK] MySQL stop
/etc/init.d/amh-start: line 10: kill: (21633) - No such process
/etc/init.d/amh-start: line 10: kill: (25911) - No such process
/etc/init.d/amh-start: line 10: kill: (25945) - No such process
/etc/init.d/amh-start: line 10: kill: (26885) - No such process
/etc/init.d/amh-start: line 10: kill: (27007) - No such process
/etc/init.d/amh-start: line 10: kill: (27230) - No such process
/etc/init.d/amh-start: line 10: kill: (27535) - No such process
/etc/init.d/amh-start: line 10: kill: (27611) - No such process
/etc/init.d/amh-start: line 10: kill: (27704) - No such process
/etc/init.d/amh-start: line 10: kill: (28310) - No such process
/etc/init.d/amh-start: line 10: kill: (28368) - No such process
/etc/init.d/amh-start: line 10: kill: (28812) - No such process
/etc/init.d/amh-start: line 10: kill: (38161) - No such process
/etc/init.d/amh-start: line 10: kill: (38191) - No such process
/etc/init.d/amh-start: line 10: kill: (38211) - No such process
/etc/init.d/amh-start: line 10: kill: (38231) - No such process

---字符限制删掉一部分错误---

/etc/init.d/amh-start: line 10: kill: (38698) - No such process
/etc/init.d/amh-start: line 10: kill: (38708) - No such process
/etc/init.d/amh-start: line 10: kill: (38719) - No such process
/etc/init.d/amh-start: line 10: kill: (47960) - No such process
/etc/init.d/amh-start: line 10: kill: (48404) - No such process
/etc/init.d/amh-start: line 10: kill: (48562) - No such process
=============================================================
[LNMP/Nginx] Amysql Host - AMH 4.2
http://Amysql.com

Starting MySQL. SUCCESS!
[OK] MySQL start
=============================================================
[LNMP/Nginx] Amysql Host - AMH 4.2
http://Amysql.com

[Notice] All PHP start...
=============================================================
[LNMP/Nginx] Amysql Host - AMH 4.2
http://Amysql.com

[Notice] xxxx.com PHP start...
[OK] xxxx.com PHP start
=============================================================
[LNMP/Nginx] Amysql Host - AMH 4.2
http://Amysql.com

[Notice] xxxx.com PHP start...
[OK] xxxx.com PHP start
=============================================================
[LNMP/Nginx] Amysql Host - AMH 4.2
http://Amysql.com

[Notice] xxxx.com PHP start...
[OK] xxxx.com PHP start
=============================================================
[LNMP/Nginx] Amysql Host - AMH 4.2
http://Amysql.com

[Notice] aaaaaaaaaaaaaaaaaa.com PHP start...
[OK] aaaaaaaaaaaaaaaaaa.com PHP start
Starting pure-config.pl: Running: /usr/local/sbin/pure-ftpd --daemonize -A -c50 -B -C8 -D -E -fftp -H -I15 -lpuredb:/etc/pureftpd.pdb -lunix -L10000:8 -m4 -s -U133:022 -u100 -k99 -Z -p10100:10110

=============================================================
[LNMP/Nginx] Amysql Host - AMH 4.2
http://Amysql.com

[OK] Nginx start




实在是不懂怎么排错,找问题了。 麻烦有哪位高手帮我看下刚从什么地方入手找文问题。
或者是找哪些错误日志:'(


2015-04-25 18:05:56 1

chen_off
铁牌会员
24.00 价值分

本帖最后由 chen_off 于 2015-4-25 20:33 编辑

Nginx 错误日志这个文件。
==============================
2015/04/25 00:24:59 [notice] 24719#0: signal process started

PHP错误日志
=================
[16-Mar-2015 16:40:08] ERROR: An another FPM instance seems to already listen on /tmp/php-cgi.sock
[16-Mar-2015 16:40:08] ERROR: FPM initialization failed
[27-Mar-2015 16:15:38] ERROR: An another FPM instance seems to already listen on /tmp/php-cgi-aaaaaaaaaaaaaa.com.sock
[27-Mar-2015 16:15:38] ERROR: FPM initialization failed
[22-Apr-2015 19:49:15] ERROR: An another FPM instance seems to already listen on /tmp/php-cgi-aaaaaaaaaaaaaa.com.sock
[22-Apr-2015 19:49:15] ERROR: FPM initialization failed
[23-Apr-2015 12:49:14] ALERT: [pool aaaaaaaaaaaaaa.com] pm.min_spare_servers(5) and pm.max_spare_servers(900) cannot be greater than pm.max_children(99)
[23-Apr-2015 12:49:14] ERROR: failed to post process the configuration
[23-Apr-2015 12:49:14] ERROR: FPM initialization failed
[23-Apr-2015 13:06:28] ALERT: [pool aaaaaaaaaaaaaa.com] pm.min_spare_servers(5) and pm.max_spare_servers(900) cannot be greater than pm.max_children(99)
[23-Apr-2015 13:06:28] ERROR: failed to post process the configuration
[23-Apr-2015 13:06:28] ERROR: FPM initialization failed
[23-Apr-2015 14:18:56] ERROR: An another FPM instance seems to already listen on /tmp/php-cgi-aaaaaaaaaaaaaa.com.sock
[23-Apr-2015 14:18:56] ERROR: FPM initialization failed
[24-Apr-2015 10:13:03] ERROR: An another FPM instance seems to already listen on /tmp/php-cgi-aaaaaaaaaaaaaa.com.sock
[24-Apr-2015 10:13:03] ERROR: FPM initialization failed
[24-Apr-2015 13:00:02] ERROR: An another FPM instance seems to already listen on /tmp/php-cgi-aaaaaaaaaaaaaa.com.sock
[24-Apr-2015 13:00:02] ERROR: FPM initialization failed
[24-Apr-2015 15:15:35] ALERT: [pool www] pm.min_spare_servers(500) and pm.max_spare_servers(500) cannot be greater than pm.max_children(400)
[24-Apr-2015 15:15:35] ERROR: failed to post process the configuration
[24-Apr-2015 15:15:35] ERROR: FPM initialization failed
[24-Apr-2015 15:18:43] ALERT: [pool www] pm.min_spare_servers(500) and pm.max_spare_servers(500) cannot be greater than pm.max_children(400)
[24-Apr-2015 15:18:43] ERROR: failed to post process the configuration
[24-Apr-2015 15:18:43] ERROR: FPM initialization failed
[24-Apr-2015 15:22:32] ALERT: [pool www] pm.min_spare_servers(500) and pm.max_spare_servers(500) cannot be greater than pm.max_children(400)
[24-Apr-2015 15:22:32] ERROR: failed to post process the configuration
[24-Apr-2015 15:22:32] ERROR: FPM initialization failed
[24-Apr-2015 15:33:52] ALERT: [pool www] pm.min_spare_servers(500) and pm.max_spare_servers(500) cannot be greater than pm.max_children(400)
[24-Apr-2015 15:33:52] ERROR: failed to post process the configuration
[24-Apr-2015 15:33:52] ERROR: FPM initialization failed
[24-Apr-2015 15:43:05] ERROR: Unable to remove the PID file (/usr/local/php/var/run/pid/php-fpm-aaaaaaaaaaaaaa.com.pid).: No such file or directory (2)
[24-Apr-2015 17:54:11] ERROR: Unable to remove the PID file (/usr/local/php/var/run/pid/php-fpm-aaaaaaaaaaaaaa.com.pid).: No such file or directory (2)
[24-Apr-2015 18:57:56] ERROR: Unable to remove the PID file (/usr/local/php/var/run/pid/php-fpm-aaaaaaaaaaaaaa.com.pid).: No such file or directory (2)
[24-Apr-2015 19:12:25] ERROR: Unable to remove the PID file (/usr/local/php/var/run/pid/php-fpm-aaaaaaaaaaaaaa.com.pid).: No such file or directory (2)
[25-Apr-2015 00:13:53] ERROR: Unable to remove the PID file (/usr/local/php/var/run/pid/php-fpm-floridafitnesstesting.com.pid).: No such file or directory (2)
[25-Apr-2015 00:13:53] ERROR: Unable to remove the PID file (/usr/local/php/var/run/pid/php-fpm-cloostudio.com.pid).: No such file or directory (2)
[25-Apr-2015 00:13:53] ERROR: Unable to remove the PID file (/usr/local/php/var/run/php-fpm.pid).: No such file or directory (2)
[25-Apr-2015 00:13:53] ERROR: Unable to remove the PID file (/usr/local/php/var/run/pid/php-fpm-childhoodinspired.com.pid).: No such file or directory (2)
[25-Apr-2015 01:20:01] ERROR: An another FPM instance seems to already listen on /tmp/php-cgi-aaaaaaaaaaaaaa.com.sock
[25-Apr-2015 01:20:01] ERROR: FPM initialization failed
[25-Apr-2015 03:00:01] ERROR: An another FPM instance seems to already listen on /tmp/php-cgi-aaaaaaaaaaaaaa.com.sock
[25-Apr-2015 03:00:01] ERROR: FPM initialization failed
[25-Apr-2015 05:00:01] ERROR: An another FPM instance seems to already listen on /tmp/php-cgi-aaaaaaaaaaaaaa.com.sock
[25-Apr-2015 05:00:01] ERROR: FPM initialization failed
[25-Apr-2015 05:40:02] ERROR: An another FPM instance seems to already listen on /tmp/php-cgi-aaaaaaaaaaaaaa.com.sock
[25-Apr-2015 05:40:02] ERROR: FPM initialization failed
[25-Apr-2015 06:40:02] ERROR: An another FPM instance seems to already listen on /tmp/php-cgi-aaaaaaaaaaaaaa.com.sock
[25-Apr-2015 06:40:02] ERROR: FPM initialization failed
[25-Apr-2015 07:20:01] ERROR: An another FPM instance seems to already listen on /tmp/php-cgi-aaaaaaaaaaaaaa.com.sock
[25-Apr-2015 07:20:01] ERROR: FPM initialization failed
[25-Apr-2015 08:20:01] ERROR: An another FPM instance seems to already listen on /tmp/php-cgi-aaaaaaaaaaaaaa.com.sock
[25-Apr-2015 08:20:01] ERROR: FPM initialization failed
[25-Apr-2015 14:08:19] ERROR: Unable to remove the PID file (/usr/local/php/var/run/pid/php-fpm-floridafitnesstesting.com.pid).: No such file or directory (2)
[25-Apr-2015 14:08:19] ERROR: Unable to remove the PID file (/usr/local/php/var/run/pid/php-fpm-aaaaaaaaaaaaaa.com.pid).: No such file or directory (2)
[25-Apr-2015 14:23:32] ERROR: Unable to remove the PID file (/usr/local/php/var/run/pid/php-fpm-aaaaaaaaaaaaaa.com.pid).: No such file or directory (2)
[25-Apr-2015 16:40:01] ERROR: An another FPM instance seems to already listen on /tmp/php-cgi-aaaaaaaaaaaaaa.com.sock
[25-Apr-2015 16:40:01] ERROR: FPM initialization failed
[25-Apr-2015 16:41:24] ERROR: An another FPM instance seems to already listen on /tmp/php-cgi-aaaaaaaaaaaaaa.com.sock
[25-Apr-2015 16:41:24] ERROR: FPM initialization failed
[25-Apr-2015 17:31:50] ERROR: Unable to remove the PID file (/usr/local/php/var/run/pid/php-fpm-aaaaaaaaaaaaaa.com.pid).: No such file or directory (2)
[25-Apr-2015 17:49:38] ERROR: An another FPM instance seems to already listen on /tmp/php-cgi-aaaaaaaaaaaaaa.com.sock
[25-Apr-2015 17:49:38] ERROR: FPM initialization failed
[25-Apr-2015 18:01:22] ERROR: Unable to remove the PID file (/usr/local/php/var/run/pid/php-fpm-childhoodinspired.com.pid).: No such file or directory (2)
================



回头想想配置什么都没有问题。
刚才在论坛里面搜索了 php-fpm 关键词,偶然发现一个帖子里面有 查询流量的词语,想起程序中有打开自己域名的CURL代码。
用 netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n 查看了下。观察了一段时间发现自己服务器的IP的访问量有 700-6000之间。
使用CURL的访问应该是非常快速的,不知道为什么访问会一直滞留下来。

目前已经修改掉程序,观察中。




  支持 (0分)  反对 (0分)
回复  2015-04-25 19:28:25 2

chen_off
铁牌会员
24.00 价值分

网站在运行一段时间后还是会出现 400 bad request ,问题没有解决。
  支持 (0分)  反对 (0分)
回复  2015-04-25 21:06:57 3

iCharlesC
银牌会员
2462.08 价值分

你试试从下面几个方面调试 (你的机器配置来看,几乎可以忽略机器性能导致的问题)

1. request header过大所引起,request过大,通常是由于cookie中写入了较大的值所引起。
在nginx.conf中,将client_header_buffer_size和large_client_header_buffers都调大,可缓解此问题。

其中主要配置是client_header_buffer_size这一项,默认是1k,所以header小于1k的话是不会出现问题的。

2. 看看 error log, 看出现 400 的时候,有没下面的错误

XXXXXXXX upstream sent too big header while reading response header from upstream XXXXX

把 proxy_buffer_size 调大 试试看

3. 有些时候也许是个人自己的浏览器导致的(清除浏览器的cookie应能解决)。 如果你的电脑碰到 400, 试试在其他电脑打开网站看看。
  支持 (0分)  反对 (0分)
回复  2015-04-25 22:58:57 4

iCharlesC
银牌会员
2462.08 价值分

当然,从你发出来的log,可以看到 php-fpm 有些配置不是正确,例如下面的,最好都相应调整好

pm.min_spare_servers(5) and pm.max_spare_servers(900) cannot be greater than pm.max_children(99)
  支持 (0分)  反对 (0分)
回复  2015-04-25 22:59:59 5
 1  (总1页)
AMH社区列表
用户服务中心