看到huoding.com上有比较好的帖子,于是理解并用自己的话来描述啦
加大client_header_buffer_size和large_client_header_buffers可以解决问题,但是为毛要两个参数来控制呢?一个不久可以满足要求了么?
client_header_buffer_size用来缓存请求头,如果超过的话就会返回400错误了。但是如果绝大多数请求不会超过这个值的话,那么更大的请求头可以受large_client_headers_buffers的影响。
还是贴nginx的原话吧
- client_header_buffer_size: Sets buffer size for reading client request header. For most requests, a buffer of 1K bytes is enough. However, if a request includes long cookies, or comes from a WAP client, it may not fit into 1K. If a request line or a request header field does not fit into this buffer then larger buffers, configured by the large_client_header_buffers directive, are allocated.
- large_client_header_buffers: Sets the maximum number and size of buffers used for reading large client request header. A request line cannot exceed the size of one buffer, or the 414 (Request-URI Too Large) error is returned to the client. A request header field cannot exceed the size of one buffer as well, or the 400 (Bad Request) error is returned to the client. Buffers are allocated only on demand. By default, the buffer size is equal to 8K bytes. If after the end of request processing a connection is transitioned into the keep-alive state, these buffers are released.
用两个参数来控制缓存大小的原因是为了平衡内存资源和处理速度的矛盾。
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:(转)Request Header Or Cookie Too Large(Nginx config) - Python技术站