【问题标题】:Nginx 502 error on Incognito Mode隐身模式下的 Nginx 502 错误
【发布时间】:2018-12-02 18:39:14
【问题描述】:

我的 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
}

【问题讨论】:

    标签: wordpress nginx server-administration


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-14
      • 2011-05-14
      • 2019-06-05
      • 2015-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-07
      相关资源
      最近更新 更多