-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Regression in 4.1.5: UriComponentsBuilder.fromHttpRequest sets port to 80 i.s.o nothing/443 [SPR-12771] #17368
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
Bart Van Bos commented I have tracked down the introduction of this issue to the following commit |
Bart Van Bos commented Introduced in f84c458 |
Damien Coraboeuf commented Hi, With the following settings in an Nginx SSL reverse proxy:
I would expect the computed URL by the In Spring 4.1.2, no problem ; but I see this regression in 4.1.5. I think the culprit code is this condition:
It was not existing in the In the situation indicated above, we fall in the case where the Damien. |
Rossen Stoyanchev commented I think that particular line of code is fine and hasn't changed. The issue is that after refactoring the code to move it from ServletUriComponentsBuilder into the more widely available UriComponentsBuilder, the starting point includes a port value, so this line picks up the port: UriComponentsBuilder builder = UriComponentsBuilder.fromUri(uri); I'll try to add a fix soon to try. |
Rossen Stoyanchev commented There is a fix now available in both branches. If you can please give it a try. |
Damien Coraboeuf commented Great news. Have you any idea when the 4.1.6 would be delivered? Just to know if I design the workaround in the meantime or if I just wait. Thanks. |
Brian Clozel commented It's due on March 25th - you can check the official release date at any time on the dedicated page. |
Damien Coraboeuf commented Thanks. I should have known... |
Bart Van Bos commented Verified as fixed in latest 4.1.6. |
Elnur Abdurrakhimov commented This hasn't been fixed. I'm still running into it with Spring Boot 1.2 and Spring 4.1.6. Had to revert to Spring Boot 1.1 and Spring 4.0.9 to make my API work again. Please reopen the ticket. |
Elnur Abdurrakhimov commented I figured the cause. It doesn't work without setting the header X-Forwarded-Port to 443. It did work without this header in Spring 4.0.x though. |
Bart Van Bos opened SPR-12771 and commented
Hi,
I am using spring-hateoas to generate URL links between my REST managed resources. Since the upstep from Spring 4.1.4 -> 4.1.5, I'm having problems with the PORT/SCHEME combination generated.
Example link before the update:
Example link after the update:
As you can see, it automatically append port 80 to the URL. The problem is that my rest back-end is running on a cloud platform heroku, which is using a reverse proxy to terminate the TLS (HTTPS).
This worked well before the update since the port was not automatically appended and the browser could figure out the port by negotiation. By hard coding it (by taking it form the original request), this auto detecting is not possible anymore.
These are my headers:
I believe the problem lies in UriComponentsBuilder.fromHttpRequest:
In my case X-Forwarded-Port == 443, so the builder.port should be set to 443 or left blank (not filled with 80 as is now the case).
Affects: 4.1.5
Reference URL: spring-projects/spring-hateoas#301
Issue Links:
Referenced from: commits 410fc6d, d64c48f
2 votes, 7 watchers
The text was updated successfully, but these errors were encountered: