Apache Proxy Pass on Ubuntu

The Apache module mod_proxy can be used to 'reverse proxy' requests through an Apache server to another server. This is most useful when proxying requests to a server behind a firewall which is not directly accessible from the internet. In this example there are 2 servers internalserver.com and externalserver.com There is an application running at the root of internalserver.com which we would like to make available externally at the address: http://externalserver.com/internalapp

  1. Enable mod_proxy with

    a2enmod proxy

    This will place a symbolic link from

    /etc/apache2/mods-enabled/proxy.conf -> /etc/apache2/mods-available/proxy.conf

  2. Inside a Virtual Host definition add (ProxyRequests should be off – on is a security risk without further controls):

    ProxyRequests Off
    ProxyPass /internalapp http://internalserver.com
    ProxyPassReverse /internalapp http://internalserver.com

  3. Edit /etc/apache2/mods-enabled/proxy.conf
    <Proxy *>
    Order deny,allow
    Deny from all
    #Allow from .your_domain.com
    </Proxy>
    The Deny from all line needs changed to allow the reverse proxy to work.
  4. Reload Apache

    /etc/init.d/apache2 reload

  5. Test the internal application on the external server at: http://externalserver.com/internalapp

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>