Steps To Reverse Proxy Tomcat To Apache Httpd


This is a summary on how to reverse proxy for Tomcat to be handled by Apache Httpd.

1. Apache Httpd installed, if you don't have that, simply just apt install apache2
2. You already have Tomcat running on port 8080, this should be really good link digitalocean - install tomcat
3. These are some Apache httpd module that you should enable

a2enmod proxy & a2enmod proxy_http & a2enmod proxy_ajp & a2enmod rewrite & a2enmod deflate & a2enmod headers & a2enmod proxy_balancer & a2enmod proxy_connect & a2enmod proxy_html

If those modules weren't installed, then install it first. 
4. This configuration will do reverse proxy for your Tomcat port 8080 to be pointed to Apache httpd  port 80, so here's settings for your 000-default.conf.

<VirtualHost *:80>
    ProxyPreserveHost On
    ServerName yourweb.com
    ServerAlias www.yourweb.com
    ServerAdmin admin@yourweb.com
    ProxyPass / http://0.0.0.0:8080/
    ProxyPassReverse / http://0.0.0.0:8080/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

All you have to do now is reload and restart your Apache httpd, normal Linux would be just sudo service apache2 reload & sudo service apache2 restart. That's all, now you have Tomcat reverse-proxied. Please let me know if something isn't work, so i can fix it.

Popular posts from this blog

ERROR 1348 Column Password Is Not Updatable When Updating MySQL Root Password

How To Create Spring Boot Project Using Netbeans

Spring Kafka - How to use ReplyingKafkaTemplate send and reply synchronously