getURI() in EurekaServiceInstance misses custom contextPath.
See original GitHub issueI have several Spring Boot Apps with REST endpoints with custom server.contextPath
’s
which use @EnableDiscoveryClient
to register themselves in the eureka service registry.
The applications are registered with eureka at startup and later queried
by a management application. I just found out that the URI
s returned by
org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient.EurekaServiceInstance.getUri()
only contain scheme,hostname and port but no custom context-path.
The URI
s were returned by discoveryClient.getInstances(serviceId)
where
discoveryClient
is an EurekaDiscoveryClient
.
The URI one gets via
public URI getUri() {
return DefaultServiceInstance.getUri(this);
}
looks like:
http://localhost:8761
The proper URI would be:
http://localhost:8761/mycontextpath/
I fixed tested this by locally shadowing the org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient
and replacing the body of the URI getUri()
method with:
@Override
public URI getUri() {
//HACK to get proper URI with context-path back
//return DefaultServiceInstance.getUri(this);
return URI.create(this.instance.getHomePageUrl());
}
With that adjustment the org.springframework.cloud.client.ServiceInstance
that I got back
returned the proper service URI
s.
I think the op of the issue #500 has the same problem.
Another Problem was that I needed to explicitly declare a
@Bean
public EurekaInstanceConfig eurekaConfigBean() {
return new EurekaInstanceConfigBean();
}
in order to get custom eureka instance settings in an applications.yml
file taken into account at
all but I guess that’s for another issue 😉
server:
port: 9999
context-path: /admin
...
eureka:
instance:
statusPageUrlPath: /admin/manage/info
homePageUrlPath: /admin/
healthCheckUrlPath: /admin/manage/health
non-secure-port: ${server.port:9999}
...
Issue Analytics
- State:
- Created 8 years ago
- Reactions:13
- Comments:56 (15 by maintainers)
Top GitHub Comments
We’ve decided as a team not to support this.
It’s all or nothing and doing “all” is a big effort.