且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

400 Bad Request - 请求标头或 cookie 太大

更新时间:2023-01-03 18:16:05

It's just what the error says - Request Header Or Cookie Too Large. One of your headers is really big, and nginx is rejecting it.

You're on the right track with large_client_header_buffers. If you check the docs, you'll find it's only valid in http or server contexts. Bump it up to a server block and it will work.

server {
    # ...
    large_client_header_buffers 4 32k;
    # ...
}

By the way, the default buffer number and size is 4 and 8k, so your bad header must be the one that's over 8192 bytes. In your case, all those cookies (which combine to one header) are well over the limit. Those mixpanel cookies in particular get quite large.