Spring

 Spring Cloud Gateway 400 err

Kyle Abu's profile image
Kyle Abu posted Nov 12, 2019 07:55 PM

Hi I have 3 apps which they are talking to each other everything works fine outside pcf but when I deploy them in pcf I get 400 Bad Request Request Header Or Cookie Too Large nginx

 

The 3 app are:

  1. webapp calls a SCG to access a resource server.
  2. SCG which will forward the request with the auth token to resource server.
  3. Resource server protected by PCF UAA.

 

 

Any help highly appreciated.

 

 

 

Daniel Mikusa's profile image
Daniel Mikusa

OK, somewhere in the request path your request is hitting a limit on a server regarding header/cookie size. You need to look at the request path to your app and see where this is happening. The typical request path looks like this: Browser -> Your Platform LBs -> Gorouter -> SCG -> Resource Server. Check each hop and confirm which one is causing the problem, then increase the maximum allowed header/cookie size so that it allows your request to pass through.

Kyle Abu's profile image
Kyle Abu

Thank you for answering but after I downgrade from spring boot 2.2.1 to 2.1.10 and from spring cloud Hoxiton to Greenwich it works with no issue​

Daniel Mikusa's profile image
Daniel Mikusa

Well, you didn't check to see where exactly is generating the 400 response so this is just speculation, but if you change the Spring Boot version and the problem goes away, it could be coming from your Spring Boot app. Spring Boot embeds a server, defaults to Tomcat, into your application. This server will put limits on the header/cookie size like all servers do to prevent DoS attacks.

 

For Tomcat, it is:

maxHttpHeaderSize   The maximum size of the request and response HTTP header, specified in bytes. If not specified, this attribute is set to 8192 (8 KB).

https://tomcat.apache.org/tomcat-9.0-doc/config/http.html#Standard_Implementation

 

You could try bumping that up. With Spring Boot, the property to set is `server.max-http-header-size` (also defaults to 8K). That should apply to all embedded servers (Tomcat, Jetty, etc..).