Skip to content
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

ServletUriComponentsBuilder should replace context path when X-Forwarded-Prefix is present [SPR-16650] #21191

Closed
spring-projects-issues opened this issue Mar 27, 2018 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Mar 27, 2018

Antonio Petrelli opened SPR-16650 and commented

ServletUriComponentsBuilder.fromContextPath, if the X-Forwarded-Prefix header is present, prepends the header value to the context path.
It should, instead, replace it, since this is what ForwardedHeaderFilter does.

In my case I see URLs in Spring Data Rest results are affected.

Workaround: use ForwardedHeaderFilter instead of relying on ServletUriComponentsBuilder.


Affects: 4.3.14

Issue Links:

Referenced from: commits 986d219, 240d6f5

Backported to: 4.3.15

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Mar 27, 2018

Rossen Stoyanchev commented

X-Forwarded-Prefix support was added with #17105 in 4.1.3 and has always worked by prepending. The ForwardedHeaderFilter was added later in 4.3 but the conclusion there was to replace the contextPath.

We'll also need to change fromRequest(request) and fromRequestUri(request) to replace the contextPath portion of request.getRequestURI() rather than simply prepending.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants