问题原文
原帖链接 · TBJ · CC BY-SA 3.0
I have a site built in Drupal 7 on a nginx server. A few times a week when I edit any content and press save, or when I log in to the site, or when I change some configuration, I get a white screen with the message "502 Bad gateway". The error is never showed to anonymous visitors, only when logged in and saving changes. It doesn't seem to matter what kind of changes I do. I can press the back button in the browser, which takes me back to the edit screen and press save again, and save the change successfully.
The error happened again this morning at 08:09, so I looked at the PHP log:
2016/10/20 08:09:00 [error] 20703#20703: *3297348 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 195.198.76.66, server: www.example.com, request: "POST /node/88/edit HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "www.example.com", referrer: "http://www.example.com/node/88/edit"
And here is the nginx log at that same time:
[20-Oct-2016 08:09:00] WARNING: [pool www0] child 10909, script '/srv/www/example/public_html/index.php' (request: "POST /index.php") execution timed out (8189.954999 sec), terminating
[20-Oct-2016 08:09:00] WARNING: [pool www0] child 10909 exited on signal 15 (SIGTERM) after 19080.476683 seconds from start
[20-Oct-2016 08:09:00] NOTICE: [pool www0] child 13002 started
Can anyone see what is happening here?
社区高分解答
原帖链接 · antoineMoPa · CC BY-SA 4.0
I had a HTTP 502 problem on a setup with nginx & php-fpm. It seems that many timeouts & limits must be modified according to the data transfer time. What was happening in this case is that the keepalive timeout was too short.
Here are some settings that might help solve 502 problems:
- In nginx.conf:
keepalive_timeout - In the site's configuration file (which is in the
sites-availablefolder):send_timeoutfastcgi_connect_timeoutfastcgi_send_timeoutfastcgi_read_timeout
- in
php.ini:max_execution_timemax_input_time
The real source of the problem can be any of these settings.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
