nginx:报错upstream sent too big header(nginx 1.24)
一,报错信息:
访问网站时报错:如图:
查看nginx的错误日志:
2023/06/16 10:21:46 [error] 416087#0: *71148 upstream sent too big header while reading response
header from upstream, client: 223.72.69.14, server: blog.liuhongdi.com,
request: "GET /index.php/2023/06/11/go-fa-song-get-qing-qiu-bing-jie-xi-fan-hui-json-go1-16-4/ HTTP/1.1",
upstream: "fastcgi://127.0.0.1:9000", host: "blog.liuhongdi.com",
referrer: "https://blog.liuhongdi.com/"
二,解决:
编辑nginx.conf
在 php的配置中添加:
fastcgi_buffer_size 128k;
fastcgi_buffers 1024 32k;
说明:
fastcgi_buffer_size 默认值4k|8K,
读取 fastcgi 应答第一部分需要多大缓冲区
默认值太小,需要调大此数值
fastcgi_buffers默认值 8 4k|8K
分配多少个缓冲区缓冲fastcgi的应答请求
完整的例子:
location ~ \.php {
fastcgi_buffer_size 128k;
fastcgi_buffers 1024 32k;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
重启nginx服务
[root@img conf]# systemctl restart nginx.service
说明:刘宏缔的架构森林—专注it技术的博客,
网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/06/20/nginx-bao-cuo-upstream-sent-too-big-header/
代码: https://github.com/liuhongdi/ 或 https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: 371125307@qq.com
三,查看nginx的版本:
[root@img ~]$ /usr/local/soft/nginx-1.24.0/sbin/nginx -v
nginx version: nginx/1.24.0