Well if you need to run tomcat to use HTTPS thene you need keystore to be created and if you need to run the same in 443 port you need to configure ubuntu to allow tomcat using the privileged ports. Port numbers less that 1024 are privileged ports. So you need to do the follows steps. I am very unsure of how much you have done or achieved.Meanwhile I detail the following steps.
Tomcat7 on Privileged Ports (:80,443)
1) In server.xml, change the line
<Server port="8005" shutdown="SHUTDOWN">
<Connector port="80" maxHttpHeaderSize="8192" protocol="HTTP/1.1"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"
socketBuffer="18000"
compression="on" URIEncoding="UTF-8"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="application/javascript,text/html,text/xml,text/javascript,text/css,text/plain,application/json,text/json,a pplication/xml"/>
<Connector port="443" maxHttpHeaderSize="8192" protocol="HTTP/1.1" SSLEnabled="true"
scheme="https" secure="true"
keystoreFile="/path/to/my.keystore" keystorePass="changeit"
clientAuth="false" sslProtocol="TLS"
maxThreads="350" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" acceptCount="100"
connectionTimeout="60000" disableUploadTimeout="true"
bufferSize="4096"
compression="on"
compressionMinSize="2048" URIEncoding="UTF-8"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="application/javascript, text/html, text/xml,text/javascript, text/css,text/plain, application/json,text/json,application/xml"/>
2) Install authbind
sudo apt-get install authbind
3) Make port 80 available to authbind (you need to be root):
sudo su
touch /etc/authbind/byport/80
chmod 500 /etc/authbind/byport/80
chown tomcat7 /etc/authbind/byport/80
touch /etc/authbind/byport/443
chmod 500 /etc/authbind/byport/443
chown tomcat7 /etc/authbind/byport/443
4) Make IPv4 the default (authbind does not currently support IPv6).
To do so, create the file $TOMCAT_HOME/bin/setenv.sh with the following
content:
CATALINA_OPTS="-Djava.net.preferIPv4Stack=true"
AUTHBIND=yes
5) Change /usr/share/tomcat7/bin/startup.sh last line to something as follows.
exec authbind --deep "$PRGDIR"/"$EXECUTABLE" start "$@"
# OLD: exec "$PRGDIR"/"$EXECUTABLE" start "$@"
Tomcat Keystore generation steps:
- To generate SSL key, run the following command in the Terminal
$JAVA_HOME/bin/keytool -genkey -alias Tomcat -keysize 2048 -keyalg RSA
-validity 3650 -keystore /path/to/my.keystore
Provide the necessary information and set the password. The default password is “changeit”.
- Grant execute permission to the my.keystore file
chmod 777 /path/to/my.keystore
Thats it.
Note: I have posted connector tags of tomcat server.xml for a production environment. if you are running it in pre-production environment with low server config better avoid or reduce options inside the tags like max-min-Threads, lookups, timesouts etc at your ease.