Skip to content

Commit c289ba0

Browse files
committed
Recommend disabling context root redirects with proxied Tomcat
Closes gh-22908
1 parent 28ccf54 commit c289ba0

File tree

2 files changed

+5
-1
lines changed
  • spring-boot-project

2 files changed

+5
-1
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ public static class Tomcat {
372372

373373
/**
374374
* Whether requests to the context root should be redirected by appending a / to
375-
* the path.
375+
* the path. When using SSL terminated at a proxy, this property should be set to
376+
* false.
376377
*/
377378
private Boolean redirectContextRoot = true;
378379

spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,9 @@ With this option, the Web servers themselves natively support this feature; you
856856
If this is not enough, Spring Framework provides a {spring-framework-docs}web.html#filters-forwarded-headers[ForwardedHeaderFilter].
857857
You can register it as a Servlet Filter in your application by setting `server.forward-headers-strategy` is set to `FRAMEWORK`.
858858

859+
TIP: If you are using Tomcat and terminating SSL at the proxy, configprop:server.tomcat.redirect-context-root[] should be set to `false`.
860+
This allows the `X-Forwarded-Proto` header to be honored before any redirects are performed.
861+
859862
NOTE: If your application runs in Cloud Foundry or Heroku, the configprop:server.forward-headers-strategy[] property defaults to `NATIVE`.
860863
In all other instances, it defaults to `NONE`.
861864

0 commit comments

Comments
 (0)