Apache has many modules bundled with it that are available but not enabled in a fresh installation. First, you’ll need to enable the ones you’ll use in this tutorial.
The modules you need are mod_proxy
itself and several of its add-on modules, which extend its functionality to support different network protocols. Specifically, you 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
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer
sudo a2enmod lbmethod_byrequests
To put these changes into effect, restart Apache.
sudo systemctl restart apache2
Apache is now ready to act as a reverse proxy for HTTP requests.