Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

400 bad request on nginx proxy to tomcat but not on static content

We have been running into an issue when our cookies reach a certain size (over 7k) where nginx is returning 400 Bad Request with an empty response when proxying to our tomcat. This doesn't happen when nginx is serving the static content however. We have already tried updating the nginx config to increase the buffer size so it should handle individual headers up to 16k (we've also tried to set it on server level):

http {
  # ...
  client_body_buffer_size     32k;
  client_header_buffer_size 16k;
  large_client_header_buffers 4 16k;
  # ...
}

We have also upped the tomcat max-http-header-size to 16k. If we increase the cookie size to over 16k we still get a 400 bad request but the response has the "Request Header Or Cookie Too Large" error message. Something strange is happening between 8k and 16k header sizes that we can't figure out.

like image 953
cnaut Avatar asked Nov 09 '22 02:11

cnaut


1 Answers

This does not appear to be an nginx issue, as it's unlikely for it to be returning empty pages, which are usually the classic tomcat signature.

It would appear that setting up the header size may depend on the connector that you're using:

  • Setting Max HTTP Header Size With AJP / Tomcat 6.0
like image 155
cnst Avatar answered Nov 15 '22 06:11

cnst