502 upstream sent too big header while reading response header from upstream
程序员文章站
2022-03-15 15:50:31
...
错误502 upstream sent too big header while reading response header from upstream sudo gedit /var/log/nginx/error.log 查看错误日志 upstream sent too big header while reading response header from upstream 你去搜这个错误,网上的解释都差不多,无外乎是cookie携带的header太多了,让你设置: fastcgi_buffer_size 128k; fastcgi_buffers 8 128k; 逐步尝试。其中fastcgi_buffers 8 128k 这句,fastcgi_buffers 32 32k 这样更好,内存是整块分配和释放的,减少单位k数能尽可能利用。 另外,如果你用nginx做负载均衡的话,改了上述参数是没用的,要在转发的配置上,比如以下设置: location @to_other { proxy_buffer_size 128k; proxy_buffers 32 32k; proxy_busy_buffers_size 128k; add_header X-Static transfer; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://backend; #请求转发 } 以下三行才会起作用。 proxy_buffer_size 128k; proxy_buffers 32 32k; proxy_busy_buffers_size 128k; fastcgi_* 可以理解成nginx接受client请求时的响应使用的。proxy是nginx作为client转发时使用的,如果header过大,超出了默认的1k,就会引发上述的upstream sent too big header。
location ~ \.php$ { fastcgi_buffer_size 128k; fastcgi_buffers 32 32k; include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /host/web/$fastcgi_script_name; }
上一篇: memcache 启动
下一篇: oracle 表空间满
推荐阅读
-
Centos7---nginx---upstream prematurely closed connection while reading response header from upstream
-
nginx 报 upstream sent too big header while reading response header from upstream
-
「recv() failed while reading response header from upstream」
-
502 upstream sent too big header while reading response header from upstream
-
502 upstream sent too big header while reading response header from upstream