1
votes

I have setup a local environment with a couple Spring Cloud services (config, service registry, and Zuul). The proxy correctly exposes the services using the default mapping:

2015-11-23 14:06:30.184  INFO 11532 --- [           main] o.s.c.n.zuul.web.ZuulHandlerMapping      : Mapped URL path [/api-proxy/**] onto handler of type [class org.springframework.cloud.netflix.zuul.web.ZuulController]
2015-11-23 14:06:30.184  INFO 11532 --- [           main] o.s.c.n.zuul.web.ZuulHandlerMapping      : Mapped URL path [/service-discovery/**] onto handler of type [class org.springframework.cloud.netflix.zuul.web.ZuulController]
2015-11-23 14:06:30.184  INFO 11532 --- [           main] o.s.c.n.zuul.web.ZuulHandlerMapping      : Mapped URL path [/config-service/**] onto handler of type [class org.springframework.cloud.netflix.zuul.web.ZuulController]
2015-11-23 14:06:30.184  INFO 11532 --- [           main] o.s.c.n.zuul.web.ZuulHandlerMapping      : Mapped URL path [/circuitbreaker-collector/**] onto handler of type [class org.springframework.cloud.netflix.zuul.web.ZuulController]
2015-11-23 14:06:30.184  INFO 11532 --- [           main] o.s.c.n.zuul.web.ZuulHandlerMapping      : Mapped URL path [/circuitbreaker-dashboard/**] onto handler of type [class org.springframework.cloud.netflix.zuul.web.ZuulController]

The problem I am seeing is that when I go to http://localhost/service-discovery/ I see the Eureka dashboard but none of the related static resources load. Browser shows errors like:

http://localhost/eureka/css/wro.css Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/eureka/js/wro.js Failed to load resource: the server responded with a status of 404 (Not Found)
service-discovery:223 Uncaught ReferenceError: $ is not defined
http://localhost/eureka/css/wro.css Failed to load resource: the server responded with a status of 404 (Not Found)

Is there a way to get around this issue? From what I can tell Eureka dashboard isn't using a relative path when loading resources and instead assumes the app is deployed to the root servlet context.

UPDATE I realized I miss represented the problem. I commented on this thread but thought I would bring it up to the main post. The issue is that Zuul makes the backend request on behalf of the client. When Zuul makes that request the HTML response contains URL's that are relative to the context path that was configured for Eureka. Normally proxy services would manage this by re-writing any URLs found in the response to have the correct base context in regard to how the proxy is exposing it. Does something like this exist for Zuul?

Changed subject to better describe the issue.

1
Yes, you can change the context of the eureka server and tell zuul to not strip prefixes. But I question why you want the dashboard to be served through zuul.spencergibb
I understand in normal situations this wouldn't be exposed through Zuul. I was just playing around with the connectivity between services with a Zuul proxy.Shawn Clark
The way this is normally managed for other proxy type services is that URLs in the response from the backend service get re-written so that the context from Zuul gets applied to those URLs. Is that something that Zuul offers and is that the recommended approach when using Zuul?Shawn Clark
Looks like this issue was raised in context of Spring Cloud Zuul: github.com/spring-cloud/spring-cloud-netflix/issues/8Shawn Clark

1 Answers

2
votes

I think the reason is that the context-paths are different between home page and static file, I solved that problem by setting up them apart:

registry:
  path: /registry/**
  url: http://localhost:8006/
  strip-prefix: true
registry-static:
  path: /eureka/**
  url: http://localhost:8006/eureka/