Reputation: 465
SpringBoot 2.3.0, SpringMVC, latest spring-cloud-starter-netflix-zuul.
I have a ZUUL proxy service which has the following rule:
zuul.routes.service1.path=/campaigns/**
zuul.routes.service1.url=http://localhost:8081/campaignmanagement/campaigns
The forwarded request contains correct X-Forwarded-*
headers AND the incorrect X-Forwarded-Prefix
: "campaigns"
If I request http://proxy:8080/campaigns, the target service (service1
), generates this url: http://proxy:8080/campaigns/campaigns when i call
ServletUriComponentsBuilder.fromCurrentRequest().build().toUriString()
(Notice the duplicate "campaigns" path!)
I use the SpringBoot config property server.forward-headers-strategy=FRAMEWORK
.
The ForwardedHeaderFilter
appends to the current SpringMVC path to the forwardedPrefix:
private String initRequestUri() {
return this.forwardedPrefix != null ? this.forwardedPrefix + this.pathHelper.getPathWithinApplication((HttpServletRequest)this.delegate.get()) : null;
}
Can I do anything here? is ZUUL the problem or the ForwardedHeaderFilter.
Upvotes: 0
Views: 788
Reputation: 3
I have exactly the same problem. I don't know if the only solution is to create a custom Zuul filter to remove this header at the beginning with the highest predence.
I know that it is possible to enable/disable per header with Spring Cloud Gateway but I think is not possible with Zuul.
Upvotes: -1