rocky
rocky

Reputation: 5004

Zuul or eureka set host header to service instance host

We are using three instances of same service, they are registered in eureka. There is zuul in front of them.

Whenever our service try to redirect to one of controllers ( for example /login) it goes directly to hostname: port (visible in browser address field) instead going through zuul proxy again. This gives us timeout. We are tracking headers which goes into service - there is host header set to hostname of our service.

Shouldn't it use address from x-forwarded-host instead? How to force zuul/eureka to do that? Or we should tweak some spring-boot configuration to use it instead host?

Upvotes: 2

Views: 3011

Answers (1)

Ákos Ratku
Ákos Ratku

Reputation: 1421

Your service is sending a location header with it's own host. You either modify the service so that references your base host, or you write a zuul filter which modifies the response header before sending it to the client.

Here is a guide for filters: https://github.com/Netflix/zuul/wiki/Writing-Filters

You can modify the headers through RequestContext .

If you make a bean out of your filter, it will be registered without any action on your behalf.

Upvotes: 2

Related Questions