I have a tomcat web app in an Ubuntu
server. The web app is deployed as ROOT
. I have installed apache2
and via a VirtualHost
I pointed the IP directly to the tomcat web app. So I can access the site via the IP (and domain) directly like 125.20.20.50
or example.com
.
Please check the below file, which is the 000-default.conf
in \etc\apache2\sites-enabled\
.
<VirtualHost *:80>
ProxyPreserveHost On
# Servers to proxy the connection, or;
# List of application servers:
# Usage:
# ProxyPass / http://[IP Addr.]:[port]/
# ProxyPassReverse / http://[IP Addr.]:[port]/
# Example:
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
ServerName localhost
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /opt/apache-tomcat-7.0.79/webapps/ROOT/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine On
# Set the path to SSL certificate
# Usage: SSLCertificateFile /path/to/cert.pem
SSLCertificateKeyFile /etc/apache2/ssl/key.key
SSLCertificateFile /etc/apache2/ssl/certificate.crt
SSLCertificateChainFile /etc/apache2/ssl/STAR_xxx_com.ca-bundle
ProxyPreserveHost On
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
ServerName localhost
</VirtualHost>
The SSL works fine if I specifically used https
in the URL like https://portal.example.com
. The case is I still can access the site without security if I didn't specifically mention the https
but typed something like portal.example.com
in browser.
How can I fix this?