Configure Reverse Proxy – CentOS 7 – httpd

By default mod_proxy is included in http package.

Had created a new VM – So installing httpd

yum clean all
yum -y update
yum -y install httpd
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=8080/tcp
systemctl start httpd
systemctl enable httpd
systemctl status httpd

Configure the proxy/reverse proxy.

Create new config file

<os-prompt># vi /etc/httpd/conf.d/r_proxy.conf

<IfModule mod_proxy.c>
    ProxyRequests Off
    <Proxy *>
        Require all granted
    # Proxy to which server?
    ProxyPass / http://<ip>:<port>/
    ProxyPassReverse / http://<ip>:<port>/

Restart httpd

systemctl restart httpd

When I tried to access http://proxyserverip/myapp

I got “Service Unavailable”.

In /var/log/httpd/error_log I could see

[Thu Jul xx xx:xx:xx:xxxxxx 2016] [proxy:error] [pid 11966] AH00959: ap_proxy_connect_backend disabling worker for (<targetserverip>) for 60s

Solution was to configure SELinux with following

/usr/sbin/setsebool -P httpd_can_network_connect 1

And it worked!