Wednesday 28 August 2019

Apache Reverse Proxy Configuration

To configure a reverse proxy in Apache the conf file should be created in Apache Proxy Conf folder. You can run multiple instances of Apache Proxies on a single Server. In this example, I have created abc.xyz.com.conf file to configure the reverse proxy.
$ pwd
/etc/httpd/conf.proxies.d



$ cat abc.xyz.com.conf



--VirtualHost 63.2.77.187:80
  ServerName abc.xyz.com
  RedirectPermanent / https://abc.xyz.com/

--/VirtualHost
--VirtualHost 63.2.77.187:443
  ServerName abc.xyz.com
  ErrorLog logs/proxies/abc.xyz.com.err.log
  CustomLog logs/proxies/abc.xyz.com.acc.log combined
  --/VirtualHost

--IfModule ssl_module
    SSLEngine on
    SSLProxyEngine on
    SSLCertificateFile cert.d/abc.xyz.com.crt
    SSLCertificateKeyFile cert.d/abc.xyz.com.key
    SSLCertificateChainFile cert.d/abc.xyz.com.IntermediateCA.crt
  --/IfModule ssl_module


  # Proxy for /
  --Location /
    ProxyPass https://redirect_URL.com/
    ProxyPassReverse https://redirect_URL.com/
  --/Location

  # Proxy for /world
--Location /world/
    ProxyPass https://redirect_URL2.com/
    ProxyPassReverse https://redirect_URL2.com/
  --/Location






Note: The Certificates are placed in the .cert folder. IntermedaiteCA is the rootCA Certificate.


Once configuration is done.  use these commands to restart or check status. A stop/start is required post any configuration changes in this file.




sudo systemctl start httpd
sudo systemctl stop httpd
sudo systemctl status httpd




Other details:


SSL Certificates         ---> /etc/httpd/cert.d
Proxy Configurations ---> /etc/httpd/conf.proxies.d
Apache Logs              ---> /etc/httpd/logs/
Proxy Logs                 ---> /etc/httpd/logs/proxies/

No comments:

Post a Comment