How to set up apache2 reverse proxy on Ubuntu 16.04/18.04/20.04 LTS - TechBeginner

Welcome to TechBeginner.in, Tech Beginner provides technical blog for Online Linux Tutorials, Ubuntu Tutorials, Redhat Tutorials and CentOS 7, Configuration of server like Web Server, Application server, Database server, Window server, networking, html, css, java script, php, wordpress, opencart, magento, joomla and etc.

How to set up apache2 reverse proxy on Ubuntu 16.04/18.04/20.04 LTS

Share This


Apache Web Server - Turn around intermediary is the point at which an intermediary worker (for this situation, Apache2 HTTP) acknowledges all traffic and advances it to a particular asset, similar to a backend worker or compartment.. The backend worker can be either another Apache2 or open source HTTP worker like Nginx… 

Apache2 HTTP worker is one of the most well known open source web workers that is being used today… It's not normally utilized as an intermediary worker, yet can be in the event that you need to utilize it as one.. 

There are numerous motivations to introduce and utilize an intermediary worker… Example, turn around intermediary can be utilized to included security, or for load adjusting, limit access to specific areas so as to forestall assaults and some more…


Install Apache2

$ sudo apt-get update
$ sudo apt-get install apache2

Test Apache2 Web Page

Open your browser with http://localhost/ if you get the Apahce2 test page, Apache2 installation is working fine.

Enable Apache2 Proxy

$ sudo a2enmod proxy
$ sudo a2enmod proxy_http

cd /etc/apache2/sites-available

$ sudo vim reverse_proxy.conf
 

Paste and change the following configuration according to your requirement in my case i am using localhost:8080 for reverse proxy.

 <VirtualHost *:80>
        ServerName example.com
        ServerAlias www.example.com
        ServerAdmin webmaster@example.com
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        ProxyRequests Off
        <Proxy *>
          Order deny,allow
          Allow from all
        </Proxy>
        
        ProxyPass / http://localhost:8080/
        ProxyPassReverse / http://localhost:8080/

        <Location />
          Order allow,deny
          Allow from all
        </Location>

</VirtualHost>


Save and Exit from the editor.

$ sudo a2ensite reverse_proxy.conf 

Check Apache Configuration file

$ sudo apachectl configtest 

Reload the Apache2 Services 

$ sudo systemctl reload apache2

No comments:

Post a Comment