Nginx Web 服务器错误 - 从上游读取响应标头时上游发送了太大的标头

Lac*_*ung 1 php nginx laravel

我设置了一个 nginx Web 服务器来运行我正在开发的两个站点,它们基本上是相同的站点,具有相同的配置,基于 Laravel 框架构建。两者都有登录设置,但每次我尝试登录时,其中一个都会给出 502 错误。每当我尝试登录时,都会收到 502 错误,如果我检查 nginx 错误日志,我会看到以下内容:

2020/10/21 22:26:59 [错误] 10400#10400: *12 上游在从上游读取响应标头时发送了太大的标头,客户端:162.158.179.216,服务器:vms2.medlab.co,请求:“POST /登录 HTTP/1.1”,上游:“fastcgi://unix:/run/php/php7.4-fpm.sock:”,主机:“vms2.medlab.co”,引荐来源:“https://vms2.medlab .co/”

我的网站的conf文件如下,与我的其他网站完全相同,运行得很好:

#http
server {
    listen         80;
    server_name    vms2.medlab.co;
    root           /var/www/vms.medlab.co/current/public;
    index          index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    location ~* \.php$ {
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass unix:/run/php/php7.4-fpm.sock;
      include         fastcgi_params;
      fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
      fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
    }
}

# HTTPS
server {
  listen 443 ssl http2;
  server_name vms2.medlab.co;
  root        /var/www/vms.medlab.co/current/public;
  index       index.php index.html index.htm;


  #ssl on;
  ssl_certificate         /etc/nginx/ssl/cloudflare-medlab.co.crt;
  ssl_certificate_key     /etc/nginx/ssl/cloudflare-medlab.co.key;

  location ~ /\. {
    deny all;
  }


  location / {
    access_log /var/www/vms.medlab.co/logs/access.log combined;
    error_log /var/www/vms.medlab.co/logs/error.log;
    try_files $uri $uri/ /index.php?$query_string;
  }

  location ~* \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    include         fastcgi_params;

    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
  }
}
Run Code Online (Sandbox Code Playgroud)

我发现人们在快速 cgi 方面遇到了很多问题,并尝试了一些快速修复,但到目前为止还没有成功。有人遇到过类似的事情吗?还有什么我应该尝试的吗?

提前致谢

chrome 502 错误

Lac*_*ung 5

发现问题了!

必须在 nginx.conf 文件中添加以下内容

    http { 
...
    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;
    fastcgi_connect_timeout 90;
    fastcgi_send_timeout 90;
    fastcgi_read_timeout 90;
}
Run Code Online (Sandbox Code Playgroud)