I am trying to front my tomcat
installation with Apache 2
webserver. The idea is to let apache
handle the SSL/https
part and then forward the normal request to the tomcat on same machine running on port 8080.
As mentioned here, I am using the following configuration :
<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
ServerName my-server-name.com
</VirtualHost>
Listen 443
NameVirtualHost *:443
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /etc/letsencrypt/archive/my-server-name.com/cert-file
SSLCertificateKeyFile /etc/letsencrypt/archive/my-server-name.com/key-file
SSLCertificateChainFile /etc/letsencrypt/archive/my-server-name.com/chain-file
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>
The above configuration is resulting in :
- Visiting
http://my-server-name.com
is opening thetomcat
landing page - Visiting
https://my-server-name.com
is opening theapache
landing page
But what I expect is to always redirect to https://my-server-name.com
which should open the tomcat
landing page (which will evantually be replaced by my application deployed on the ROOT)
Can someone please guide me or any pointer to a step by step guide to front tomcat
with apache
for https
to http
handling
Best Answer
The first vhost isn't needed as it seems and the
NameVirtualHost
directive can also be dropped, resulting in: