无痕模式下的Nginx 502错误

时间:2018-06-23 14:47:17

标签: wordpress nginx server-administration

我的NGINX服务器遇到一个奇怪的问题。该网站打开,并且在关闭隐身浏览时可以正常运行,但是对于任何新的浏览器/会话,我都收到NGINX 502 Bad Gateway错误。我在错误日志中只有以下内容。

  

[错误] 2121#2121:* 34上游在从上游读取响应标头时发送了太大的标头,客户端:xx.xx.xx.xx,服务器:domain.tld,请求:“ GET / HTTP / 2.0”,上游:“ fastcgi:// unix:/run/php/php7.2-fpm.sock:”,主机:“ domain.tld”

配置文件已附加

server {

server_name domain.tld  www.domain.tld;

root   /var/www/html/domain.tld/public_html;
index  index.html index.php;
http2_push_preload on;

location / {
    try_files $uri $uri/ /index.php?$args;
    proxy_buffer_size          128k;
    proxy_buffers              4 256k;
    proxy_busy_buffers_size    256k;
    }
location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME /var/www/html/domain.tld/public_html$fastcgi_script_name;
}

    location = /xmlrpc.php {
        deny all;
        }

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; allow all; }
            location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
    expires max;
    log_not_found off;
}

    location ~ /\.ht {
    deny all;
}

location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
    add_header "" "";
    }

location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
# managed by Certbot

listen 443 ssl http2; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/domain.tld/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain.tld/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}
server {
if ($host = www.domain.tld) {
    return 301 https://$host$request_uri;
} # managed by Certbot


if ($host = domain.tld) {
    return 301 https://$host$request_uri;
} # managed by Certbot



server_name domain.tld www.domain.tld;
listen 80;
return 404; # managed by Certbot
}

1 个答案:

答案 0 :(得分:0)

通过在我的nginx配置文件中添加以下指令来修复它

fastcgi_max_temp_file_size 0;
fastcgi_buffers 128 2048k;
fastcgi_buffer_size 2048k;

希望它可以帮助无法解决此错误的人:)