Skip to content

ForwardedHeaderFilter should support cases where contextPath should not be replaced with X-Forwarded-Prefix [SPR-14376] #18949

Closed
@spring-projects-issues

Description

@spring-projects-issues

Thibaud Lepretre opened SPR-14376 and commented

With latest ForwardedHeaderFilter executed on Spring application that is using context-path

server.context-path: /bar

If X-Forwarded-Prefix: /foo is present the following url http://blabla.com/bar/oauth/authorize will be converted to http://blabla.com/foo/oauth/authorize

However with following architecture (1) Reverse proxy SSL with context path /foo, (2) Zuul without context path and (3) Microservice BAR with context path /bar: rendering request will not work because http://blabla.com/foo/oauth/authorize will be 404.

Expected result should be http://blabla.com/foo/bar/oauth/authorize.

However I'm aware that for some other use cases context-path should be replaced and not prepended (like I wish). So the issue is debatable.

Possible solutions:

  1. Clearly document that X-Forwarded-Prefix will not really prefix but replace the existing context-path
  2. Add option to choose strategy between prepending or replacing
  3. If you consider it as a bug, just prepend.

For example Spring cloud netflix prepends X-Forwarded-Prefix during Zuul filtering https://github.com/spring-cloud/spring-cloud-netflix/pull/994/files#diff-8a3a3948fd59a02ea4234d960437c3a0R120


Affects: 4.3 GA

Issue Links:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions