业务中一个php的接口get信息的时候 ,会偶然引起nginx 502 错误
查看nginx错误日志 得到报错信息:
upstream sent too big header while reading response header from upstream
可以看出是header头信息过大引起nginx报错
需要修改nginx的主配置文件
在http模块加入
http {
proxy_buffer_size 128k;
proxy_buffers 4 128k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
}
在server块的配置中加入
location ~ .php$ {
fastcgi_buffer_size 128k;
fastcgi_buffers 4 128k;
fastcgi_busy_buffers_size 256k;
}
注意 proxy_temp_file_write_size 的值必须要大于等于 proxy_buffer_size 和 proxy_buffers的值,否则nginx会报错
"proxy_temp_file_write_size" must be equal to or greater than the maximum of the value of "proxy_buffer_size" and one of the "proxy_buffers" in /usr/local/nginx/config/nginx.conf:134
参考链接
https://stackoverflow.com/questions/13894386/upstream-too-big-nginx-codeigniter