Canada  united states of america usa  linkedinfacebook   Call Us Today: 866.646.6461

Enabling mod_proxy on Apache

A reverse proxy is a type of proxy server that takes HTTP requests and seamlessly distributes them to one or more backend servers. These are useful as apache load-balancers or a central location for web applications. (For example, if you have a main domain, you can have a subdirectory pointed to a web application located on a completely different server. Eg: https://www.example.com/ as the main domain and https://www.example.com/myapp can be sitting on a completely different server)

Since you are here, you are most likely looking how to enable this feature. We are using Ubuntu server, but the process is similar across all Linux based apache installs.

sudo a2enmod ssl
sudo a2enmod proxy
sudo a2enmod proxy_balancer
sudo a2enmod proxy_http

Once all these modules were enabled, restart apache:

service apache2 restart

Usage:

Within virtulhost file, specify the app path on the server:

ProxyPass /myapp/ http://172.16.0.12/recordings/
ProxyPassReverse /myapp/ http://172.16.0.12/recordings/

Where:

/myapp/ is the URL which will be used to access the proxied path (ie from the public server www.example.com/myapp/)

http://172.16.0.12/recordings/ is the url pointing to the internal server (the server that is being proxied)

ProxyPass and ProxyPassReverse are the back and forth communication. One sends requests to the server, while the other sends back the responses.

Last updated Feb 23, 2021