我的NGINX服务器遇到了一个奇怪的问题。该网站在浏览隐身时打开并正常运行,但对于任何新的浏览器/会话,我都收到 NGINX 502 错误网关错误。我在错误日志中只有以下内容。
[错误] 2121#2121:*34 上游在从上游读取响应标头时发送的标头太大,客户端:xx.xx.xx.xx,服务器:domain.tld,请求:"GET/HTTP/2.0",上游:"fastcgi://unix:/run/php/php7.2-fpm.sock:",主机:"域.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
}
通过将以下指令添加到我的nginx配置文件来修复它
fastcgi_max_temp_file_size 0;
fastcgi_buffers 128 2048k;
fastcgi_buffer_size 2048k;
希望它可以帮助无法修复此错误的人:)