分类: Linux
Nginx 414 Request-URI Too Large报错解决方法

症状:前台客户端发送大量请求或发送的数据包太大的时候,nginx会报nginx 414 Request-URI Too Large错误,如下图
Nginx
检查Log里面显示有大量报错

2019/04/09 15:03:32 [error] 21197#0: *90489 client intended to send too large body: 1470779 bytes, client: 124.74.25.254, server: zt-test.xxx.cn, request: "POST /cinema/salesman/save HTTP/1.1", host: "zt-test.xxx.cn:8080", referrer: "http://zt-test.xxx.cn:8080/index"
2019/04/09 15:22:37 [error] 21200#0: *90745 client intended to send too large body: 1376065 bytes, client: 114.86.94.252, server: zt-test.xxx.cn, request: "POST /cinema/salesman/save HTTP/1.1", host: "zt-test.xxx.cn:8080", referrer: "http://zt-test.xxx.cn:8080/index"
2019/04/10 09:08:46 [error] 21200#0: *91741 client intended to send too large body: 1470779 bytes, client: 124.74.25.254, server: zt-test.xxx.cn, request: "POST /cinema/salesman/save HTTP/1.1", host: "zt-test.xxx.cn:8080", referrer: "http://zt-test.xxx.cn:8080/index
原因:当请求头过大时,超过large_client_header_buffer时,nginx可能返回"Request URI too large" (414)或者"Bad-request"(400)错误,请求投中最长的一行也要小于large_client_header_buffer,当不是Request line的最长行大于一个buffer(128k)时,会返回"Bad-request"(400)错误

解决方法:在nginx.conf的http段中加入以下参数:

client_header_buffer_size 512k;
large_client_header_buffers 4 512k;
client_max_body_size 100m;

重启nginx即可

/usr/local/nginx/sbin/nginx -s reload


相关博文:

发表新评论