-
Notifications
You must be signed in to change notification settings - Fork 472
x-forwarded-proto broken in Spring Boot 2.1.1 #753
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
Thanks for the report, unfortunately, there isn't enough information here to diagnose where the problem might have been introduced. Can you please provide a minimal sample (something that we can unzip or git clone and run) that reproduces the behaviour you have described? |
Spring Framework 5.1 (from Boot 2.1) alters forwarded header handling and we haven’t merge our patch to compensate for this. See #713. |
Do you then need this zip @gregturn ? Or do you have enough context? |
Either way, here it is @gregturn, @wilkinsona, just upgrade boot and you'll see that one test failing. |
#758 has been merged to master and backported so you can find it in Spring HATEOAS If you test your app against this most recent change (and also configure Forwarded headers properly with Spring MVC), your issue should clear up. If not, please provide more details. |
Edit: I have moved to a new desktop and for whatever reason I can't reproduce the issue anymore. |
If this is purely Spring Boot and not Spring HATEOAS then you need to open a ticket with Spring Boot. |
@gregturn You said
Is this still coming? It would be tremendously helpful for us if a fix could be released soon. |
Test it out against |
we currently use this SNAPSHOT and it works. |
To see whether spring-projects/spring-hateoas#753 is fixed for us
To see whether spring-projects/spring-hateoas#753 is fixed for us
It unfortunately does not work for us. With Spring Boot 2.0, the protocol worked, based on the |
Have you created the right filter? If you check this ticket there’s a link about how to properly activate forwarded headers. |
* YD-261 Testing Spring HATEOAS 0.25.1.BUILD-SNAPSHOT To see whether spring-projects/spring-hateoas#753 is fixed for us * YD-621 set server.use-forward-headers=true To enable interpretation of headers like X-Forwarded-For and X-Forwarded-Proto. This wasn't necessary before, but seems to be a new requirement for us.
After adding With my confirmation (and also from @jenny1976), would you be willing and able to release 0.25.1? |
@gregturn |
Spring Framework now defaults with Forwarded header support disabled. So you have to use that setting for any apps you need from here on. I’ll consult with @odrotbohm about seeing if we can get a patch release out the door. |
@gregturn Any news on this? |
We can ship an 0.25.1 next week for inclusion in Spring Boot 2.1.3. |
That would be great. Thanks in advance! |
Once the patch is release would the "spring-boot-starter-hateoas" automatically pull the new patch 0.25.1.RELEASE as its dependency? |
That will require a separate patch. However, at any point, you can put this into your build file:
...and adjust it based on the release. (Comparable mod available if you are using Gradle). |
Saw a comment from @Bert-R mentioning that server.use-forward-headers=true works to bypass this issue in case of Spring Boot. Is there any Spring 5 XML equivalent for this? |
If anybody struggles with this issue there is a fine workaround (?):
taken from https://stackoverflow.com/a/53269319 |
Spring HATEOAS 0.25.1 was just released and is ready for pickup in Spring Data Lovelace SR coming tomorrow and Spring Boot 2.1 maintenance release. |
@dinkarchaturvedi Besides setting |
* YD-261 Testing Spring HATEOAS 0.25.1.BUILD-SNAPSHOT To see whether spring-projects/spring-hateoas#753 is fixed for us * YD-621 set server.use-forward-headers=true To enable interpretation of headers like X-Forwarded-For and X-Forwarded-Proto. This wasn't necessary before, but seems to be a new requirement for us. * YD-621 Added extra assert to verify proxy settings
Thanks @Bert-R . The Spring setting server.use-forward-headers appears to be specific to Spring Boot (I could be wrong) and meant to be used within application.properties file. |
There is a bean definition listed above with a link to SO showing how to define the necessary bean. |
Thanks @gregturn . Apologies for posting on a closed issue but none of the solutions mentioned in this thread have helped my case. The SO link suggests to use FilterRegistrationBean which is available in SpringBoot but not as part of Spring Core 5.1 so I can't use that. |
i´ve recently upgraded from 1.5.4 to 2.1.4 and i´ve had the same issue. With server.use-forward-headers=true on application.properties it´s fixed |
Thank you very much @raphaelLacerda - adding server.use-forward-headers=true fixed it for me as well. |
For future readers,
|
Can somebody explain how NATIVE and FRAMEWORK are different for this property? When should I use one over the other? |
See the Javadoc on the corresponding enum. |
I did. But it doesn't give enough information for me to choose between Native/Framework. All it says is who handles forwarded headers for corresponding values. servlet container? or spring framework? but it brings back to square 1. Should I let container handle it? or the framework? when Should I prefer one over the other? I've posted a question on stackoverflow regarding the same |
There already is an answer and discussion on the Stack overflow post. This ticket is the least appropriate place to discuss this. |
For the following test:
And the following implementation:
Or alternatively with controller links, e.g.:
I get the test passing in Spring Boot 2.0.7 and failing in Spring Boot 2.1.1 - because the link gets
http
instead ofhttps
.I checked Spring Hateoas in both boot releases and it remains 0.25.0. Obviously, this makes me think this issue doesn't belong here. However, I was hoping you could help me reassign it where it belongs?
The text was updated successfully, but these errors were encountered: