简体   繁体   English

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

[英]how to run tomcat in https and port 80?

I am trying to host a website on Centos + tomcat7 , if I run tomcat7 on port 80 everything works fine ie 74.208.164.45 but if I want to access it using https://74.208.164.45/ ,it doesn't work , but If I try like this https://74.208.164.45:8443/ after adding the keystore , then it works fine. 我试图在Centos + tomcat7上托管一个网站,如果我在端口80上运行tomcat7一切正常,即74.208.164.45,但如果我想使用https://74.208.164.45/访问它,它不起作用,但如果我在添加密钥库后尝试这样的https://74.208.164.45:8443/ ,那么它可以正常工作。

So, I need a way to run tomcat on 80 and https , ie https://74.208.164.45/ should work fine on port 80. Now,I am trying only with Tomcat but if it's totally not possible then I can use some Apache http server to redirect to tomcat using AJP connectors but that is the last thing I would prefer to do . 所以,我需要一种方法来运行80和https上的tomcat,即https://74.208.164.45/应该在端口80上正常工作。现在,我只尝试使用Tomcat但是如果它完全不可能那么我可以使用一些Apache http服务器使用AJP连接器重定向到tomcat,但这是我最不愿意做的事情。 Also, can we do something with the IPTables? 另外,我们可以用IPTables做点什么吗?

You need to change the Connector port for https from the default value of "8443" to "443" in server.xml 您需要将https的Connector端口从server.xml中的默认值“8443”更改为“443”

The default looks something like this: 默认看起来像这样:

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

See SSL/TLS Configuration HOW-TO from the Tomcat docs on how to setup SSL 请参阅Tomcat文档中有关如何设置SSL的SSL / TLS配置HOW-TO

This could be the full format in the server.xml 这可以是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" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM