简体   繁体   中英

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.

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 . Also, can we do something with the IPTables?

You need to change the Connector port for https from the default value of "8443" to "443" in server.xml

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

This could be the full format in the 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" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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