apache http server

How to configure Apache 2 with Tomcat

Today i will guide how to install and configure apache 2 with tomcat on Centos server using mod_proxy plugin

Scenario of this configuration:

  • Server A install web server apache and have domain app.devjav.com(this domain already point to server A)
  • Server B install tomcat server listen on port 8080
  • We need allow user access application run on tomcat server in server B through ¬†domain app.devjav.com

1. Install apache HTTP server

We install apache through yum tool, run below command to install, we use sudo if user login is not root user

[sudo] yum install httpd

In Centos the configuration file of httpd will be in /etc/httpd/conf and /etc/httpd/conf.d

2. Configure Apache HTTPD

We create file mod_proxy.conf in /etc/httpd/conf.d. Apache configuration will read all files *.conf in that folder. We add following content to that file

ProxyPass / http://{hostname or ip}:8080/
ProxyPassReverse / http://{hostname or ip}:8080/

In here hostname or ip is where tomcat server running, in this example tomcat listen on port 8080.

3. Restart apache Http server

We restart apache http server by following command to update new configuration.

[sudo] /etc/init.d/httpd restart

Now you can access application through http://app.devjav.com

Leave a Reply