最近发现Nginx+Laravel 搭建的网站搜索某些关键字时返回502错误。

查了一下Nginx的错误日志,发现如下错误

1
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段,加入下面的配置

1
2
3
proxy_buffer_size  128k;
proxy_buffers 32 32k;
proxy_busy_buffers_size 128k;

重启Nginx错误依旧。再在host配置的php段加入下面配置

1
2
3
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;

重启Nginx就不再报错了。