Jump to Navigation

277 - Configure Apache Reverse Proxy Server

Apache can be configured in both a forward and reverse proxy (also known as gateway) mode.

A reverse proxy (or gateway) appears to the client just like an ordinary web server.
No special configuration on the client is necessary. The client makes ordinary requests for content in the name-space of the reverse proxy.
The reverse proxy then decides where to send those requests, and returns the content as if it was itself the origin.

A typical usage of a reverse proxy is to provide Internet users access to a server that is behind a firewall.
Reverse proxies can also be used to balance load among several back-end servers, or to provide caching for a slower back-end server.
In addition, reverse proxies can be used simply to bring several servers into the same URL space.

1. Edit httpd.conf of Apache

# vi /etc/httpd/conf/httpd.conf

=====================================================

<IfModule mod_proxy.c>

ProxyRequests Off
RequestHeader set X_FORWARDED_PROTO 'https'
ProxyPass          /    http://www.example.com:8080/ timeout=30
ProxyPassReverse   /    http://www.example.com:8080/ timeout=30
ProxyPassReverseCookieDomain www.myserver.com www.example.com
ProxyPassReverseCookiePath / /

<Proxy *>
    Order deny,allow
    Allow from All
</Proxy>

</IfModule>

=====================================================

2. If you are configuing a virtuall host.

# vi /etc/httpd/conf/httpd.conf

=====================================================

<IfModule mod_proxy.c>

ProxyRequests Off

<Proxy *>
    Order deny,allow
    Allow from All
</Proxy>

<VirtualHost *:80>
ProxyPass          /    http://www.example.com:8080/
ProxyPassReverse   /    http://www.example.com:8080/
</VirtualHost>

</IfModule>

=====================================================

3. To use SSL port (443)

Check the following line in httpd.conf.

Include conf.d/*.conf

# vi /etc/httpd/conf.d/ssl.conf

=====================================================

    <VirtualHost _default_:443> <--- Comment out
    <VirtualHost *:443>
        ServerName IP or FQDN:443

        ..........

        #   SSL Engine Switch:
        #   Enable/Disable SSL for this virtual host.
        SSLEngine on
        SSLProxyEngine on
        RequestHeader set X_FORWARDED_PROTO 'https'
        ProxyPass / https://IP or FQDN/
        ProxyPassReverse / https:// IP or FQDN/
       
        ...........

    </VirtualHost>

=====================================================

3. Restart httpd

# service httpd restart

 

 

 



Main menu 2

Story | by Dr. Radut