将 tomcat(作为 Spring tcServer)重定向到不同的端口
我想做一些类似于 SSL 重定向的事情,但略有不同。
我有一个负载均衡器,配置为侦听端口 80 (HTTP) 和 443 (HTTPS)。
负载均衡器没有能力进行任何 SSL 重定向,因为如果它这样做了,我的生活就太容易了(顺便说一句,它是亚马逊的弹性负载均衡器)。
我有 Tomcat (tcServer) 监听两个端口:80 和 81(都是 HTTP)。
LB 上的端口 80 将带您到 tomcat 上的 80 端口。 LB 上的端口 443 将带您到 tomcat 上的端口 81(同一 Web 应用程序)。
我想要的是让 tomcat 上的端口 80 将您发送回负载均衡器上的 443。
而这一切都无需触及已部署的 Web 应用程序。
有什么想法吗?
I'd like to do something similar to SSL redirection, but slightly different.
I have a load balancer configured to listen on port 80 (HTTP) and 443 (HTTPS).
The load balancer does not have the ability to do any SSL redirection because if it did my life would be too easy (it's Amazon's Elastic Load Balancer, btw).
I have Tomcat (tcServer) listening on two ports: 80 and 81 (both HTTP).
Port 80 on the LB will take you to port 80 on tomcat.
Port 443 on the LB will take you to port 81 on tomcat (same web app).
What I would like is to have port 80 on tomcat send you back to 443 on the load balancer.
And all without touching the deployed webapp.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一种解决方法:创建一个不包含任何页面的简单 Web 项目,仅包含一个针对 404 错误的简单错误页面,它将每个请求重定向到负载均衡器的绝对 URL(带有 https:// 链接)。然后配置 Tomcat 在端口 80 上使用此应用程序(即部署为 ROOT.war)并在端口 81 上为您的原始应用程序提供服务。
One workaround: create a simple web project which does not contain any pages, just a simple error page for 404 errors which redirects every request to the absolute URL of your load balancer (with a https:// link). Then configure Tomcat to use this application on the port 80 (i.e. deploy as ROOT.war) and serve your original application on port 81.
所以显然我过度思考了这一点(嗯,根据我正在阅读的一些论坛,我有点过度思考了)。无论如何,这就是有效的(并且正在有效 - 我们正在生产中)。
,您就完成了。最终配置如下所示:
/WEB-INF/web.xml
/WEB-INF/urlrewrite.xml
为此,您只需要在一个端口上运行 tomcat 即可。对于如何启用 URLRewrite,您有两种选择。
So apparently I over thought this (well, I was kind of led into over thinking it based on some forums I was reading). In any event, here's what worked (and is working - we're in production).
And you are done. The final config looks like:
/WEB-INF/web.xml
/WEB-INF/urlrewrite.xml
You only need tomcat running on one port for this. You have two choices for how to enable URLRewrite.