如何在 https 和端口 80 中 运行 tomcat?

how to run tomcat in https and port 80?

我正在尝试在 Centos + tomcat7 上托管一个网站,如果我 运行 tomcat7 在端口 80 上一切正常,即 74.208.164.45 但如果我想添加密钥库后使用 https://74.208.164.45/ ,it doesn't work , but If I try like this https://74.208.164.45:8443/ 访问它,然后它工作正常。

所以,我需要一种在 80 和 https 上 运行 tomcat 的方法,即 https://74.208.164.45/ 应该可以在端口 80 上正常工作。 现在,我只尝试使用 Tomcat,但如果完全不可能,那么我可以使用一些 Apache http 服务器使用 AJP 连接器重定向到 tomcat,但这是我最不想做的事情。 另外,我们可以用 IPTables 做点什么吗?

您需要在 server.xml

中将 https 的连接器端口从默认值“8443”更改为“443”

默认值如下所示:

<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
           maxThreads="150" scheme="https" secure="true"
           clientAuth="false" sslProtocol="TLS" />

请参阅 Tomcat 文档中的 SSL/TLS Configuration HOW-TO,了解如何设置 SSL

这可能是 server.xml

中的完整格式
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" />

<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS"  keystoreFile="/.keystore" keystorePass="Pa$$W0rd" />