I am currently running an instance of Tomcat8 on a ubuntu server that I installed using apt-get install tomcat8
. I hosted an application and it was running fine without a SSL certificate.
Recently I bought a SSL certificate from sslcertificate.com and followed https://support.comodo.com/index.php?/Knowledgebase/Article/View/638/0/certificate-installation-java-based-web-servers-tomcat-using-keytool to install it. I was able to package it together and configure the server.xml
file.
Here is what the server.xml
file looks like:
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="443"
useIPVHosts="true"/>
<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" keyAlias="tomcat" keystoreFile="myfile.jks" keystorePass="my_pass"/>
Nothing else was changed and the server suddenly stopped working. When I try to go to my site it says that the server refused to connect. I tried to remove the changes I made to the server.xml
but it's still refusing to connect.
I tried sudo lsof -i -P -n | grep LISTEN
and this was the output:
sshd 1018 root 3u IPv4 13571 0t0 TCP *:22 (LISTEN)
sshd 1018 root 4u IPv6 13573 0t0 TCP *:22 (LISTEN)
mysqld 1083 mysql 19u IPv4 16958 0t0 TCP 127.0.0.1:3306
(LISTEN)
sshd 1351 ubuntu 9u IPv6 13938 0t0 TCP [::1]:6010 (LISTEN)
sshd 1351 ubuntu 10u IPv4 13939 0t0 TCP 127.0.0.1:6010
(LISTEN)
sshd 2623 ubuntu 9u IPv6 22382 0t0 TCP [::1]:6011 (LISTEN)
sshd 2623 ubuntu 10u IPv4 22383 0t0 TCP 127.0.0.1:6011
(LISTEN)
java 2721 tomcat8 62u IPv4 21439 0t0 TCP 127.0.0.1:8005
(LISTEN)
I'm not sure what is wrong. Any help is appreciated!
Issue SOLVED.
I searched around and was able to find a solution, it was at: https://wolfpaulus.com/java/tomcat-ssl/
The server issue was fixed by the following command:
sudo setcap cap_net_bind_service+ep /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
Restarted the server and everything worked!
Your configuration of the Connectors is using ports 80 and 443 which are both privileged ports. You need to run Tomcat as root to make this working. Otherwise, switch to non-privileged ports like 8080 and 8443 which are popular choices.