PHP program appears 502 bad gateway how to break?
Reply content:
PHP program appears 502 bad gateway how to break?
Confirm that the PHP-FPM process is healthy, and then start with the run environment and adjust the timeout and buffer size configurations.
For example a iptables + haproxy + nginx + PHP-FPM operating environment, Haproxy and Nginx can trigger 502, perhaps your PHP run time exceeded the Haproxy or Nginx timeout settings, Maybe your php output a lot of cookie data and so on.
nginx.conf Reference Adjustment
# 502 probolem solvingfastcgi_connect_timeout 60;fastcgi_send_timeout 180;fastcgi_read_timeout 180;fastcgi_buffer_size 128k;fastcgi_buffers 8 256k;fastcgi_busy_buffers_size 256k;fastcgi_temp_file_write_size 256k;fastcgi_intercept_errors off;
Haproxy.cfg Reference Adjustment
tune.bufsize 131072
PHP will not report 502 must be your front-end Web server (for example nginx
, Apache
) reported 502 errors
This error typically occurs when your front-end Web server is unable to connect to the backend CGI ( php-fpm
for example)
The further reason is that fpm hangs or is stuck (it will appear when high, memory, or CPU is not enough).