1. 程式人生 > >修復Nginx 502錯誤:upstream sent too big header while reading response header from upstream

修復Nginx 502錯誤:upstream sent too big header while reading response header from upstream

最近發現Nginx+Laravel 搭建的網站搜尋某些關鍵字時返回502錯誤。

查了一下Nginx的錯誤日誌,發現如下錯誤

2015/03/19 10:46:40 [error] 6412#0: *16436265 upstream sent too big header while reading response header from upstream, client: 192.168.101.100, server: localhost, request: "GET /search_rst.html?word=%E7%88%B1%E6%82%A0 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: ......

看來還是Nginx的配置問題。

在Nginx配置檔案的的http段,加入下面的配置

proxy_buffer_size  128k;
proxy_buffers   32 32k;
proxy_busy_buffers_size 128k;

重啟Nginx錯誤依舊。再在host配置的php段加入下面配置
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;

重啟Nginx就不再報錯了。