cPanel Nginx + PHP FastCGI因502 Bad Gateway而崩溃

I have a cPanel/WHM server with nginx and FastCGI.

When i'm loading a script that takes like 3 minutes to execute, the 502 Bad Gateway appears for all users for 1/2 seconds and disappear.

I have changed the proxy's timeout to 300, php.ini's execution time to 300 and fastcgi's timeout to 300.

But that doesn't fix the issue...

In my logs, i have that:

2018/09/02 10:53:30 [error] 18290#18290: *1737 upstream prematurely closed connection while reading response header from upstream, client:, server:, request: "GET / HTTP/1.1", upstream: "", host: ""

here is my config:

http {
## Basic Settings ##
client_body_buffer_size        128k;
client_body_timeout            300s; # Use 5s for high-traffic sites
client_header_timeout          300s; # Use 5s for high-traffic sites
client_max_body_size           1024m;
keepalive_timeout              30s;
open_file_cache                max=200000 inactive=20s;
open_file_cache_errors         on;
open_file_cache_min_uses       2;
open_file_cache_valid          30s;
port_in_redirect               off;
reset_timedout_connection      on;
send_timeout                   300s;
sendfile                       on;
server_name_in_redirect        off;
server_names_hash_bucket_size  1024;
server_names_hash_max_size     1024;
server_tokens                  off;
tcp_nodelay                    on;
tcp_nopush                     on;
types_hash_max_size            2048;
fastcgi_buffers 256 16k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;

And here is the proxy's config

# General Proxy Settings
proxy_pass                    $PROXY_SCHEME://$PROXY_DOMAIN_OR_IP:$PROXY_TO_PORT;
proxy_hide_header             Upgrade;
proxy_http_version            1.1;                # Always upgrade to HTTP/1.1
proxy_set_header              Accept-Encoding ""; # Optimize encoding
proxy_set_header              Connection "";      # Enable keepalives
proxy_set_header              Host $host;
proxy_set_header              Proxy "";
proxy_set_header              Referer $http_referer;
proxy_set_header              X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header              X-Forwarded-Host $PROXY_FORWARDED_HOST;
proxy_set_header              X-Forwarded-Port $server_port;
proxy_set_header              X-Forwarded-Proto $scheme;
proxy_set_header              X-Forwarded-Server $host;
proxy_set_header              X-Real-IP $remote_addr;
proxy_set_header              CF-Connecting-IP $http_cf_connecting_ip;
proxy_set_header              CF-Visitor $http_cf_visitor;

# Buffers
proxy_buffers                 256 16k;
proxy_buffer_size             128k;
proxy_busy_buffers_size       256k;
proxy_temp_file_write_size    256k;

# Timeouts
proxy_connect_timeout         300s;
proxy_read_timeout            300s;
proxy_send_timeout            300s;

If someone can help me... Thanks

Csdn user default icon