Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 619
Subhasish Dash Avatar asked May 29 '16 08:05

Subhasish Dash


People also ask

Can Tomcat run on both HTTP and HTTPS?

You can configure two virtual hosts (one for http and one for https) which connect to the respective Tomcat backend servlets.


1 Answers

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

like image 183
diwo Avatar answered Oct 01 '22 01:10

diwo