Dustin's Apache Proxy Guide
Created on September 23rd, 2000

Today I got a little experimental, and decided to play with the proxy module for Apache at work. It was fairly easy to setup, and I found a few quick and simple uses for it. The module comes with the Apache source code. First I enable the module and compiled it. Then, I editted my httpd.conf to reflect my needs. Then I restared Apache. I used it for 3 things...

  • 1) A normal caching proxy server

  • 2) A reverse proxy, that can basically foward service from an internal web server to the external public Internet

  • 3) Replaced the slow and inefficient Netscape internal cache with the more efficient, speedy Apache Proxy Server.

    When I install Apache, I always install from the tarball. It very easy to setup, I install to /usr/local/apache...

    
      tar -zxvf apache_x.x.xx
    
      ./configure --prefix=/usr/local/apache --enable-module=proxy
    
      make
    
      make install
    

    That should build it and install it for you quite nicely, of course if you use any other Apache Modules, and I know you all use PHP, hint hint, you will need to add your other configuration rules.

    Now you will need to edit your httpd.conf, which turns out to be a fairly simple task this time around, if you did not erase your proxy directives from your current httpd.conf, if you already use Apache. I simply uncommented all of the items between the ‹IfModule>‹/IfModule> tags for the proxy stuff, not including those tags. Then I setup which hosts I wanted to allow use of my new proxy server. Yours will differ, but I entered "localhost" and "win2k" which allow my local machine and my Windows 2000 laptop to access my proxy. Then I restarted apache:

      /usr/local/apache/bin/apachectl restart
    

    At this point I enable my web browsers to access the proxy by pointing them to my main linux box and used port 80. That gave good access to MS IE5 on Winbloze and Netscape 4.75 on Winbloze. But I was always concerned about Netscape. Even with my nice broadband access, I was getting sluggish results from Netscape. On my Windows box, IE could get things faster behind my IP Masq. This is for a certain reason. Netscape's internal cache is inferior and a poor excuse for a cache. It accesses itself very slowly. So I first, cleared my cache in Netscape, both on Winbloze and Linux, and then set there cache space to 0kb to disable caching, and voila, Netscape performed like a champ.

    I was still a little curious, and I wondered if I could do reverse proxying. This is the situation where the proxy requests things from it's internal network, intranet servers, and passes them back to the web. This is good to keep things all on the nice default port 80 that the web uses, and it allows for firewalling. I enabled this by using 2 directives in my httpd.conf, ProxyPass and ProxyPassReverse.

      ProxyPass        /win2k http://win2k
      ProxyPassReverse /win2k http://win2k
    

    What I did here is told my Apache setup to take requests from http://mydomain.com/win2k and get them from my win2k box, this is done with the ProxyPass directive. The ProxyPassReverse directive takes redirect headers sent from the win2k box and tranlates them, because the external Internet cannot see my win2k box, so Apache interprets this for it.

    This was all great, everything worked out great for me, I hope it helps you as well. Hopefully soon I will use this in conjuction with mod_rewrite and setup some load balancing :)


    Having trouble? Got questions? Require further assistance? If so please feel free to visit our Help Forums and ask the experts!