Monday, November 24, 2008

Reverse proxying with Apache 2.2

Hi:

Sometimes you need to have Apache work as a reverse proxy, for example, to expose a web server behind a firewall to the public internet, or to add SSL. This is my short example on how to do it for the SSL case, but the other one should be similar.

<virtualhost 172.16.4.179:443>
        # Define location of SSl certificates and turn SSL On.
        SSLEngine on
        SSLOptions +StrictRequire
        SSLCertificateFile /etc/ssl/certs/server.crt
        SSLCertificateKeyFile /etc/ssl/private/server.key
        # Set up reverse proxy
        ProxyRequests Off
        
                Order deny,allow
                Allow from all
        
        # Expose /ESAL with contents of http://localhost:8080/ESAL
        ProxyPass /ESAL http://localhost:8080/ESAL
        ProxyPassReverse /ESAL http://localhost:8080/ESAL
        # Expose /limesurvey with contents of http://localhost/~eortega/limesurvey
        ProxyPass /limesurvey http://localhost/~eortega/limesurvey
        ProxyPassReverse /limesurvey http://localhost/~eortega/limesurvey

</virtualhost>

Here we are exposing through SSL sites that are published on non SSL locations (http://localhost:8080/ESAL/ and http://localhost/~eortega/limesurvey/).



No comments: