how to redirect http to https for a tomcat7 webapp?

787 Views Asked by At

After installing an SSL certificate for a Tomcat7 webapp on port 8080, I managed to use https perfectly, but for some reason when I use http (or nothing, just www.myDomain.com), I get a download prompt window with an empty file, and my page gets nowhere, instead of redirecting to https.

My server.xml contains the following:

<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

and

<Connector port="8443" protocol="HTTP/1.1" maxHttpHeaderSize="8192" maxThreads="150"
minSpareThreads="25" maxSpareThreads="75" enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true" SSLEnabled="true" clientAuth="false"
sslProtocol="TLS" keyAlias="server"
keystoreFile="/etc/tomcat7/www_myDomain_com.jks" keystorePass="password" />

now, I also redirected the ports to 8443 and it doesnt work:

# iptables -t nat -L                                                                                                   
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:http redir ports 8443
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:https redir ports 8443

Any idea on what is wrong here?

thanks!!!!!

1

There are 1 best solutions below

0
On BEST ANSWER

All I needed to do is restart Tomcat, and after that, restart the browser