doudula1974 2018-09-02 12:51
浏览 71

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: x.xx.xxx.xxx, server: xxxxx.fr, request: "GET / HTTP/1.1", upstream: "https://xx.xxx.xxx.xxx:8443/", host: "xxxxxxx.fr"

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 luckysheet
    • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
    • ¥15 找一位技术过硬的游戏pj程序员
    • ¥15 matlab生成电测深三层曲线模型代码
    • ¥50 随机森林与房贷信用风险模型
    • ¥50 buildozer打包kivy app失败
    • ¥30 在vs2022里运行python代码
    • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
    • ¥15 求解 yolo算法问题
    • ¥15 虚拟机打包apk出现错误