spring-cloud-netflix icon indicating copy to clipboard operation
spring-cloud-netflix copied to clipboard

Is it possible to override the basePath used in eureka templates?

Open MikeSebetichB opened this issue 7 years ago • 9 comments

Hi, it seems that the basePath used in eureka freemarker templates (like this one) can not be overridden and is hard coded to '/' in the EurekaController. Can you please tell me if my understanding is correct? Thank you for your help.

MikeSebetichB avatar Jun 14 '17 20:06 MikeSebetichB

Can you describe why you want to change the basePath?

spencergibb avatar Jun 14 '17 20:06 spencergibb

Sure, I have my eureka server hosted under http://myserver/somePath. Since the basePath is assumed to be '/' the template is trying to load static content from http://myserver/. For example, the template tries to load http://myserver/eureka/css/wro.css but it should load http://myserver/somePath/eureka/css/wro.css. I'm open to other suggestions on how to resolve this if I can do something other than changing the basePath (I have to host it under somePath though). Thank you for your help.

MikeSebetichB avatar Jun 14 '17 20:06 MikeSebetichB

Try setting eureka.dashboard.path

spencergibb avatar Jun 14 '17 20:06 spencergibb

I looked into that but let me expand on something. http://myserver/somePath is the route to the root of my eureka service. i.e. that path is created outside of the eureka service itself. If I set eureka.dashboard.path=somePath I would then need to access the dashboard from http://myserver/somePath/somePath. Hosting the root of my service under http://myserver/somePath is unfortunately a constraint.

MikeSebetichB avatar Jun 14 '17 20:06 MikeSebetichB

It's not something we support at this time.

spencergibb avatar Jun 14 '17 20:06 spencergibb

Understood, thank you for your responses.

MikeSebetichB avatar Jun 14 '17 20:06 MikeSebetichB

Hi, I ran into a similar use case: When the eureka server is behind a gateway (e.g., zuul reverse proxy), the zuul route prefix is stripped and is put into the x-forwarded-prefix header. So, it would be nice if the basePath was configurable or was picked up from the x-forwarded-prefix header.

mgrafl avatar Jun 20 '18 13:06 mgrafl

By use ingress-nginx in k8s, there're 2 annotations for rewrite in this case (but deprecated in 0.22.0): nginx.ingress.kubernetes.io/add-base-url nginx.ingress.kubernetes.io/base-url-scheme

The generated nginx conf is: set_escape_uri $escaped_base_uri $baseuri; subs_filter '(<(?:H|h)(?:E|e)(?:A|a)(?:D|d)(?:[^">]|"[^"]*")*>)' '$1<base href="https://$http_host/xxxx/$escaped_base_uri">' ro;

I guess similar conf is required in other gateways, if eureka use static basePath.

xeniumlee avatar Feb 19 '19 09:02 xeniumlee

Bumping this issue. same as Spring Boot Admin they handle the base path (almost) the same way as you do. Very troublesome when behind a Zuul Proxy for example.

abaschen avatar May 16 '19 09:05 abaschen