How to Configure Apache Reverse Proxy

Written by deborah lee soltesz Google
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Configure Apache Reverse Proxy
Apache web server's proxy module can consolidate websites under a single host. (Die Feder image by letmeh from Fotolia.com)

Apache httpd web server can be set up as a reverse proxy (or gateway). A reverse proxy server is configured to serve content from another server. The reverse proxy server serves the content as if it were its own, using its own web address. The content from the external server is mapped under the reverse proxy server's address, so visitors are not aware the content originates from another server. Reverse proxy is used to consolidate multiple servers under a single web address, provide access to servers protected by firewalls, load balancing and to provide content caching for slow servers.

Skill level:
Easy

Other People Are Reading

Things you need

  • Apache httpd Web Server
  • Text Editor

Show MoreHide

Instructions

  1. 1

    Enable the proxy module in your Apache configuration files. Historically, the module loading is set in httpd.conf. However, your system may have Apache configuration split into multiple files. Documentation is generally found in the httpd.conf file. Look for the "LoadModule" section and uncomment or add this line:

    LoadModule proxy_module modules/mod_proxy.so

  2. 2

    Locate the web host configuration section for your server in your Apache configuration file(s). If you are using Apache's virtual hosting, you will want add the reverse proxy configuration directives in your site's <VirtualHost...> container.

  3. 3

    Turn off forward proxying by adding the following line to the host configuration:

    ProxyRequests Off

  4. 4

    Add the following lines to map a location from the reverse proxy site to an address on the external site. "ProxyPass" performs the proxying. "ProxyPassReverse" rewrites the headers returned to the client so the content is identified as originating with the reverse proxy server not the original server. Replace the "/store" location with the location name you want to use to map the external content. Replace the web server address with your back-end server address.

    ProxyPass /store http://yourserver.com/app ProxyPassReverse /store http://yourserver.com/app>

    The location is appended to the reverse proxy site address to create the URL where the external content will be accessed by visitors. So, if your front-end reverse proxy site is "http://yoursite.com", the external content in the example is accessed at the address "http://yoursite.com/store."

  5. 5

    Configure location-specific directives for the mapped location as you normally would using the Location container. Following the previous example, add a Location container:

    <Location /store> ... configuration directives... </Location>

  6. 6

    Reload or restart Apache as you normally do. Open a browser and go to the newly configured address ("http://yoursite.com/store"--the above example) to test the configuration.

Tips and warnings

  • HTML containing self-referencing addresses referring to the originating server can cause problems when the server is behind a firewall or part of a load-balancing cluster. The third-party module mod_proxy_html can be installed for Apache and used to rewrite those URLs using the front-end reverse proxy server address. See the Resources section for a link to mod_proxy_html.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.