且构网

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

400 Bad Request - 请求头或 cookie 太大

更新时间:2023-01-03 19:22:15

这正是错误所说的 - Request Header Or Cookie Too Large.你的一个头文件真的很大,nginx 拒绝了它.

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.

large_client_header_buffers 您走在正确的轨道上.如果您检查文档,您会发现它仅在 httpserver 上下文.将其连接到服务器块,它会起作用.

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;
    # ...
}

顺便说一下,默认的缓冲区数量和大小是 48k,所以你的坏头必须是超过 8192 字节的头.在您的情况下,所有这些 cookie(组合到一个标题中)都远远超过了限制.特别是那些混合面板 cookie 变得非常大.

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.