首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >没有在后端服务响应中重写URL

没有在后端服务响应中重写URL
EN

Stack Overflow用户
提问于 2015-11-23 22:12:46
回答 1查看 2.1K关注 0票数 1

我已经用两个Spring服务(配置、服务注册中心和Zuul)设置了一个本地环境。代理使用默认映射正确地公开服务:

代码语言:javascript
复制
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仪表板,但是没有一个相关的静态资源负载。浏览器显示的错误如下:

代码语言:javascript
复制
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吗?

更改主题,以更好地描述问题。

EN

回答 1

Stack Overflow用户

发布于 2018-01-15 02:54:43

我认为原因在于主页和静态文件之间的上下文路径是不同的,我通过将它们分开来解决这个问题:

代码语言:javascript
复制
registry:
  path: /registry/**
  url: http://localhost:8006/
  strip-prefix: true
registry-static:
  path: /eureka/**
  url: http://localhost:8006/eureka/
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33881700

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档