我已经用两个Spring服务(配置、服务注册中心和Zuul)设置了一个本地环境。代理使用默认映射正确地公开服务:
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]我看到的问题是,当我去http://localhost/service-discovery/时,我看到了Eureka仪表板,但是没有一个相关的静态资源负载。浏览器显示的错误如下:
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)有办法解决这个问题吗?据我所知,Eureka仪表板在加载资源时不使用相对路径,而是假设应用程序部署到根servlet上下文中。
更新我意识到我错过了这个问题。我对这篇帖子发表了评论,但我想我会把它提到主帖子上。问题是Zuul代表客户端提出后端请求。当Zuul发出请求时,HTML响应包含相对于为Eureka配置的上下文路径的URL。通常,代理服务将通过重写在响应中找到的任何URL来管理这一点,以获得有关代理如何公开它的正确的基本上下文。这样的东西存在于Zuul吗?
更改主题,以更好地描述问题。
发布于 2018-01-15 02:54:43
我认为原因在于主页和静态文件之间的上下文路径是不同的,我通过将它们分开来解决这个问题:
registry:
path: /registry/**
url: http://localhost:8006/
strip-prefix: true
registry-static:
path: /eureka/**
url: http://localhost:8006/eureka/https://stackoverflow.com/questions/33881700
复制相似问题