server.forward-headers-strategy=native: X-Forwarded-Port is not always respected in response's Location header #42804
Labels
for: external-project
For an external project and not something we can fix
status: duplicate
A duplicate of another issue
I'm using
server.forward-headers-strategy=native
because my Spring Boot (version 3.3.4) application is operating behind a Apache httpd reverse proxy. I noticed some unexpected behaviour with a few specificX-Forwarded-Port
andX-Forwarded-Proto
values.I attached a minimal sample app to demo the problem: demo.tar.gz
Here's how to reproduce the unexpected behaviour with the sample app. First start application:
Make a request to /redirect endpoint:
Response should include header
Location: https://example.com:8080/login
.Response actually includes header
Location: https://example.com:8443/login
. So, the port number is incorrect.Same happens if you change
X-Forwarded-Port
to8443
andX-Forwarded-Proto
tohttp
, the full request looks like this:Response should include header
Location: http://example.com:8443/login
.Response actually includes header
Location: http://example.com:8080/login
. Again, the port number is incorrect.Problem only occurs with the above-mentioned combinations:
X-Forwarded-Port: 8080
+X-Forwarded-Proto: https
X-Forwarded-Port: 8443
+X-Forwarded-Proto: http
If port number is any other than 8080 with forwarded-proto https or 8443 with forwarded-proto http, response's
Location
header includes the correct port number. Since the problematic port numbers are 8080 and 8443, this sounds to me like there are some Tomcat default port settings being applied somewhere.The text was updated successfully, but these errors were encountered: