I'm currently trying to get Eureka server running with URL discovery and it proofed to be a bit tricky.
According to the doc the eureka.eurekaServer.context (= eureka.client.eurekaServerURLContext) should be set to eureka/v2. This doesn't work though. The reason is that the Jersey ServletContainer is mapped at /eureka/*. Configuring context to eureka/v2 results in requests for /eureka/v2/apps/{appId} which Jersey matches against a pattern of /{version}/apps/{appId}. This pattern therefore doesn't match.
Leaving out the /eureka prefix doesn't work as the path won't be filtered by the Jersey filter. A possible workaround is to simply set the context to eureka. This results in eureka being treated as the {version} which interestingly is allowed.
The fix for this issue is to set Jersey's PROPERTY_FILTER_CONTEXT_PATH to /eureka:
@Bean
public FilterRegistrationBean jerseyFilterRegistration(
javax.ws.rs.core.Application eurekaJerseyApp) {
FilterRegistrationBean bean = new FilterRegistrationBean();
bean.setFilter(new ServletContainer(eurekaJerseyApp));
bean.setOrder(Ordered.LOWEST_PRECEDENCE);
bean.setUrlPatterns(Collections
.singletonList(EurekaServerConfigBean.DEFAULT_PREFIX + "/*"));
bean.setInitParameters(Collections.singletonMap(ServletContainer.PROPERTY_FILTER_CONTEXT_PATH, EurekaServerConfigBean.DEFAULT_PREFIX));
return bean;
}
This is obviously a major change so I'm not sure this is going to happen. Anyway, since I couldn't find any documentation on this use case though, I believe this is at least a documentation issue.
Comment From: nvj98
I can work on this documentation issue, thanks!
Comment From: igarash1
Hi, I would like to work on this issue.
Comment From: OlgaMaciaszek
Hello, @igarash1 I have assigned the issue to you. If you need any help, please contact the mentors in the Spring Cloud channel in the OpenForce discord.
Comment From: igarash1
Possibly related to #402