How to configure Apache as a reverse proxy server in Centos

Step1: Check the required Apache modules enabled or not. If its already enabled, can jump to step 5.

mod_proxy
mod_proxy_http
mod_proxy_balancer

Step2: Enable the moduled if not installed. Open the file /etc/httpd/conf.modules.d/00-proxy.conf.

#vi /etc/httpd/conf.modules.d/00-proxy.conf

Step3: Uncomment the following lines and save.

LoadModule proxy_module modules/mod_proxy.so
LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_http_module modules/mod_proxy_http.so

Step4: Restart Apache.

#systemctl restart httpd

Step5: Open virtualhost file and update the reverse proxy configuration.

<VirtualHost *:80>
    ProxyPreserveHost On
    ProxyPass / http://backendip:port/
    ProxyPassReverse / http://backendip:port/
</VirtualHost>

Here we need to replace backendip and port with the corresponding values.

Step6: Restart Apache

#systemctl restart httpd

That's all…

Leave a Reply

Your email address will not be published. Required fields are marked *