【发布时间】:2020-08-24 13:25:03
【问题描述】:
我正在寻求帮助解决我在使用 Zuul 时遇到的问题,该问题不适用于将 Tomcat 打包到 WAR 中。
独立它工作得很好,但是当我将打包更改为战争并部署到 Tomcat 时 - 请求似乎没有到达 Zuul。
我已经扩展了 SpringBootServletInitializer 并重写了 configure() 方法,但这并没有帮助。
注意:请不要建议我使用嵌入式 Tomcat 独立运行 SpringBoot - 这不起作用,因为我需要将 API 网关合并到现有的基础设施设置中。换句话说,我需要在给定边界条件的情况下实现一个网关——它必须部署在 Tomcat 应用程序服务器上。
@SpringBootApplication
@EnableZuulProxy
public class GatewayApplication extends SpringBootServletInitializer {
...
@override
protected StringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(GatewayApplication.class);
}
}
application.yml
zuul:
routes:
freebeer:
path: "/beer/**"
url: "https://freedom.com:443"
default:
path: "/**"
url: "http://landing.com/"
当我运行带有嵌入式 Tomcat 的独立应用程序时,它工作得非常好,例如: - 对http://localhost:8080/ 的请求很好地重定向到http://landing.com/ - 以及..:8080/beer 很好地重定向到freedom.com
但是如果将 WAR 部署到 Tomcat - 没有任何效果: - 对 http(s)://tomcat.intranet.com:12345 的请求欢迎我并告知我什么都没有,并建议添加网页内容 - 对 http(s)://tomcat.intranet.com:12345/beer 的请求给了我 404 消息,表明源服务器没有找到目标资源的当前表示,或者它不愿意透露存在的消息
看起来我遗漏了一些非常明显的东西。但是我已经没有耐心去弄清楚并寻求帮助了:)
【问题讨论】:
-
没有想法?可能我需要将战争重命名为 ROOT.war 或更改浏览器中的 URL? :)
标签: spring-boot tomcat servlets war netflix-zuul