Configuring Apache Tomcat With Apache HTTP Server - mod_proxy

Configuring Apache Tomcat With Apache HTTP Server - mod_proxy

Requests flow after this configuration: :computer: Browser :arrow_forward: Apache HTTP Server :arrow_forward: Apache Tomcat.

Install the Apache web server on Ubuntu Linux

Install the Apache Tomcat on Ubuntu Linux

Advantages of Apache Web server

• The source code of Apache is available for free to anyone and no license is required.

• It can be modified to adjust the code and also to fix errors.

• The ability to add more features and modules makes it a favorite among the techies.

• It is highly reliable and performs better.

• It can be installed easily.

• The changes made are recorded immediately, even without restarting the server.

• Apache can run on almost any operating systems like Windows, Linux etc.

• It is regularly maintained and updated.

• It is an effortless task to get help for Apache web servers, as its technical support is readily available on several websites all over the world.

• The documentation of Apache is quite useful and is very extensive.

• With Apache web server, multiple websites can be run from the same server. In other words, it can create virtual hosts on the same server.

• It is flexible.

Configuration

Enable mod_proxy

Apache has many modules bundled with it that are available but not enabled in a fresh installation.
First, we’ll need to enable the ones we’ll use in this tutorial.

The modules we need are mod_proxy itself and several of its add-on modules, which extend its functionality to support different network protocols. Specifically, we will use:

mod_proxy, the main proxy module Apache module for redirecting connections; it allows Apache to act as a gateway to the underlying application servers.
mod_proxy_http, which adds support for proxying HTTP connections.
mod_proxy_balancer and mod_lbmethod_byrequests, which add load balancing features for multiple backend servers.

To enable these four modules, execute the following commands in succession.

sudo a2enmod proxy

To put these changes into effect, restart Apache.

sudo systemctl restart apache2.service

Open default.conf file

sudo nano /etc/apache2/sites-available/000-default.conf

Below the configuration:

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

Add:

        ProxyPreserveHost On

        #Setup the proxy
		
        <Proxy *>
        Order allow,deny
        Allow from all
        </Proxy>
		
        ProxyPass / http://localhost:8080/
        ProxyPassReverse / http://localhost:8080/

Restart Apache:

sudo systemctl restart apache2.service