Search code examples
javaapachetomcatcentosiptables

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 i.e. 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 , i.e. 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?


Solution

  • 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