Apache Web Server (httpd) in RHEL and CentOS are similar.
$ yum install httpd mod_proxy mod_ssl mod_proxy_html mod_rewrite -y
httpd : httpd daemon install http server (web) apache
mod_proxy : This library usually comes by default. This helps for proxy setup (Forward / reverse)
mod_ssl : This library helps for HTTPS connection support in mod_proxy (proxy) to do for HTTPS as well
mod_proxy_html : This library supports for rewrite rule to support html, images and other content loading in apache
mod_rewrite : This library helps for rewrite rule in apache configuration.
$ grep 'mod_proxy' /etc/httpd/conf.modules.d/00- proxy.conf
Above command will show you already the mod proxy libaries loaded (LoadModule) in apache (httpd) and in the same configuration you will see for ssl (LoadModule configuration) in different *.conf
In order for apache to achieve forward and reverse proxy create below configuration.
Create reverse-proxy.conf file or your own file naming file and have the below configuration.
$ vi /etc/httpd/conf.d/reverse- proxy.conf
# Below fields helps on forward proxy request and proxy time out
ProxyRequests On
ProxyVia On
ProxyTimeout 60
# Below field helps to turn on HTTPS configurations (reverse / forward)
SSLProxyEngine On
# Proxy servers permissions
Require all granted
# Specify Forward proxy remote servers
ProxyRemote "http" "http://proxy.ebiz.abccompany. com:80"
ProxyRemote "https" "http://proxy.ebiz.abccompany. com:80"
# Specify no proxy servers
NoProxy ".abccompany.com"
# Reverse proxy urls and connectiontimeout happens when there is no response from the url
ProxyPass /foo http://www.webreference.com/ html/tutorial2/2.html connectiontimeout=5
ProxyPassReverse /foo http://www.webreference.com/ html/tutorial2/2.html
ProxyPass /bar https://vzweb2.abccompany.com connectiontimeout=5
ProxyPassReverse /bar https://vzweb2.abccompany.com
ProxyPass /geek https://www.ssllabs.com/ connectiontimeout=5
ProxyPassReverse /geek https://www.ssllabs.com/
Restart 'service httpd restart' after configuration changes.
You can add environment variables in file '/etc/sysconfig/httpd' if required.
Test it with : curl http://localhost/foo
curl http://localhost/bar
Best Article to know about forward-reverse proxy :
https://geekpeek.net/forward- reverse-apache-proxy-centos/ (The best forward and reverse proxy)
Reverse proxy well explained video link : https://www.youtube.com/watch? v=MQMIhAbPzb4