PHP program appears how to break the 502badgateway? How to break the 502 bad gateway error in the PHP program?
Reply content:
How to break the 502 bad gateway error in the PHP program?
Confirm that the php-fpm process is normal, and then adjust the timeout and buffer size configuration starting from the running environment.
For example, in an iptables + haproxy + nginx + php-fpm runtime environment, both haproxy and nginx may trigger 502. Maybe your php runtime exceeds the timeout setting of haproxy or nginx, maybe your php outputs a lot of cookie data.
Nginx. conf reference Adjustment
#502 probolem limit 60; fastcgi_send_timeout 180; fastcgi_read_timeout 180; fastcgi_buffer_size 128 k; fastcgi_buffers 8 256 k; Limit 256 k; Limit 256 k; fastcgi_intercept_errors off;
Haproxy. cfg reference Adjustment
Tune. bufsize 131072
PHP will not report 502. It must be your front-end web server (suchNginx
,Apache
) Error 502
In general, your front-end web server cannot connect to the backend cgi (suchPhp-fpm
).
The further reason is that fpm is suspended or stuck (high concurrency, insufficient memory, or insufficient CPU)