-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Recommend disabling context path redirects when using proxy-terminated SSL with Tomcat #22908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
My guess is that Spring is not involved here, and that Tomcat is the one doing the redirect. Have you tried using |
NATIVE did show the same results:
|
We did some more research. Tomcat completely ignores properties like All in all this sounds like a bug in the Tomcat configuration Spring performs. |
@philwebb, @wilkinsona, can one of you please transfer this to Spring Boot's issue tracker? |
Disabling the redirect should be sufficient to get this to work as you wish.
The
Related to this, a piece of your original configuration doesn't make sense in combination:
If you're using the Framework's forward headers strategy, Tomcat's remote IP valve will not be involved and, therefore, configuring its internal proxies will have no effect. |
Anything is possible but it isn't practical / realistic / performant for the Mapper to take account of a |
Thanks, Mark. I think we should make this a documentation issue and recommend setting |
Oh, that default
Such disrespect of |
Affects: Spring Boot v2.2.1.RELEASE
context path redirect causes protocol downgrade to http
I'm trying to run a basic Spring Boot application behind a proxy and with a context path, because later it will run on a server with other applications and inside a Docker container.
I'm having difficulties with the redirect to the context path. Here is a structural overview of the system:
When sending a request with the schema
https://<proxy-url>/<context-path>
, the Spring redirects the client tohttp://<proxy-url>/<context-path>/
. So it downgrades the protocol from https to http.I honestly don't know whether this is a bug or intended behavior. Is there a way to make Spring redirect to https instead of http. The proxy redirect contains the correct X-Forwarded-Proto, X-Forwarded-Host, X-Forwarded-Port headers.
The Curl output below shows that Spring reads the headers properly when adding the slash at the end of the context path. The Curl requests talk directly to Spring and I did set the headers manually to emulate the proxy. I also attached the code of the test application and a screenshot of the redirect within Chrome.
Request and redirect screenshot
Curl
Slash at the end of the context path
No slash at the end of the context path
Basic Spring Boot application code
Java Code
application.properties
pom.xml
The text was updated successfully, but these errors were encountered: