400 Bad Request - request header or cookie too large

前端 未结 4 574
面向向阳花
面向向阳花 2020-12-02 09:27

I am getting a 400 Bad Request request header or cookie too large from nginx with my Rails app. Restarting the browser fixes the issue. I am only storing a string id in my

相关标签:
4条回答
  • 2020-12-02 09:39

    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.

    0 讨论(0)
  • 2020-12-02 09:52

    In my case (Cloud Foundry / NGiNX buildpack) the reason was the directive proxy_set_header Host ..., after removing this line nginx became stable:

    http {
      server {
        location /your-context/ {
           # remove it: # proxy_set_header Host myapp.mycfdomain.cloud;
        }
      }
    }
    
    0 讨论(0)
  • 2020-12-02 09:53

    With respect to answers above, but there is client_header_buffer_size needs to be mentioned:

    http {
      ...
      client_body_buffer_size     32k;
      client_header_buffer_size   8k;
      large_client_header_buffers 8 64k;
      ...
    }
    
    0 讨论(0)
  • 2020-12-02 09:59

    Fixed by adding

    server {
      ...
      large_client_header_buffers 4 16k;
      ...
    } 
    
    0 讨论(0)
提交回复
热议问题