Tomcat Http 和 Https 在同一端口上

发布于 2024-09-01 13:32:11 字数 145 浏览 5 评论 0原文

我在端口 X 上有一个 Web 服务端点和一个 http 连接器。 在某些时候,此端点需要切换到 https,但在同一端口上! (我知道这不是正常的做事方式,但这是我的客户对他们正在使用的旧服务器的期望......)

有没有办法在 tomcat 中做到这一点?

I have a web-service endpoint and a http connector on port X.
At some point this endpoint needs to switch to https, but on the same port!
(I know this is not the normal way of doing things, but this is what my clients expect from an old server they are using...)

Is there a way to do it in tomcat?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

吻安 2024-09-08 13:32:11

Tomcat 无法做到这一点。HTTPS 连接器仅接受 SSL 连接。

我们内部开发了这样一个代理。这并不难做到。您只需要检查第一个传入的数据包。寻找 SSL 握手的模式。我们只寻找 CLIENT_HELLO。一旦弄清楚协议,您就可以相应地转发请求。

这实在是太难看了。如果可能的话,你不应该这样做。我们必须这样做,因为旧客户端会这样做,并且不可能全部升级。

This is not possible with Tomcat.The HTTPS connector will accept SSL connection only.

We have such a proxy developed in house. It's not that hard to do. You just need to check the first incoming packet. Looking for the pattern of SSL handshake. We only look for CLIENT_HELLO. Once you figure out the protocol, you can forward the request accordingly.

This is really ugly. You shouldn't do it if all possible. We have to do it because the legacy clients do this and it's impossible to upgrade them all.

述情 2024-09-08 13:32:11

有一种称为 HTTPS 升级的东西,即明文 HTTP 连接在形成后经双方同意升级为 HTTP。你是这个意思吗?如果是这样,Tomcat 似乎并不支持开箱即用,Java 也不支持开箱即用。您也许可以自己编写一个 Tomcat Connector 来完成此任务;在客户端,你有一个更有趣的问题;-)

但我想问为什么?端口并没有贵到你不能使用两个。

There is such a thing as HTTPS upgrade, whereby a plaintext HTTP connection is upgraded to HTTP by mutual agreement after it has been formed. Is that what you mean? If so, Tomcat doesn't seem to support it out of the box, and neither does Java out of the box either. You can probably write yourself a Tomcat Connector that will do it; on the client end you have a more interesting problem ;-)

But I would ask why? Ports aren't so expensive that you can't use two.

人海汹涌 2024-09-08 13:32:11

您不需要运行 HTTP &同一端口上的 HTTPS,在 server.xml 文件中配置 Tomcat 将请求重定向到 HTTPS。

You don't need to run the HTTP & HTTPS on same port, Configure the Tomcat to redirect requests to HTTPS in server.xml file.

倾城泪 2024-09-08 13:32:11

好吧,我想知道为什么它们通常不在同一个端口上!那不是更容易吗?

原因可能是相关的 Java APIS (javax.net.ssl) 不允许这样做;您必须有不同的服务器套接字。 Java 是否有其他替代 SSL 实现?我不知道有什么。

well I wonder why they are NOT usually on the same port! wouldn't that be easier?

the reason is probably that related Java APIS (javax.net.ssl) don't allow that; you must have different server sockets. are there any alternative SSL impls for Java? I'm not aware of any.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文