Recommend disabling context root redirects with proxied Tomcat

Closes gh-22908
This commit is contained in:
Andy Wilkinson 2020-11-04 10:13:55 +00:00
parent 28ccf54b21
commit c289ba0c2c
2 changed files with 5 additions and 1 deletions

View File

@ -372,7 +372,8 @@ public class ServerProperties {
/**
* Whether requests to the context root should be redirected by appending a / to
* the path.
* the path. When using SSL terminated at a proxy, this property should be set to
* false.
*/
private Boolean redirectContextRoot = true;

View File

@ -856,6 +856,9 @@ With this option, the Web servers themselves natively support this feature; you
If this is not enough, Spring Framework provides a {spring-framework-docs}web.html#filters-forwarded-headers[ForwardedHeaderFilter].
You can register it as a Servlet Filter in your application by setting `server.forward-headers-strategy` is set to `FRAMEWORK`.
TIP: If you are using Tomcat and terminating SSL at the proxy, configprop:server.tomcat.redirect-context-root[] should be set to `false`.
This allows the `X-Forwarded-Proto` header to be honored before any redirects are performed.
NOTE: If your application runs in Cloud Foundry or Heroku, the configprop:server.forward-headers-strategy[] property defaults to `NATIVE`.
In all other instances, it defaults to `NONE`.