Apache proxy server?

monty

Registered
I heard that apache has a built in proxy server module. Anyone know if this is true and if so how to turn it on?

peter
 
Inside your httpd.conf there is a section you need to uncomment to turn on the proxy server. If you don't have it, here is the example code they've included in the default config files.

Make sure you setup the Direcotry proxy:* correctly. You wouldn't want your proxy server being abused by people outside your network!

< IfModule mod_proxy.c >
ProxyRequests On
< Directory proxy:* >
Order deny,allow
Deny from all
Allow from .your_domain.com
< /Directory >

# Enable/disable the handling of HTTP/1.1 "Via:" headers.
# ("Full" adds the server version; "Block" removes all outgoing Via: headers)
# Set to one of: Off | On | Full | Block
ProxyVia On

CacheRoot "/usr/local/apache/proxy"
CacheSize 5
CacheGcInterval 4
CacheMaxExpire 24
CacheLastModifiedFactor 0.1
CacheDefaultExpire 1
#NoCache a_domain.com another_domain.edu joes.garage_sale.com
< /IfModule >

Note: I had to add spaces into the directives so they the braind-dead vBulletin wouldn't clobber the line. You'll probably have to remove them for Apache to parse the file correctly.
 
Thank you Cadre for your tips and help with this one. I was able to finally get the proxy server function of Apache to work using the tip above after only a few minor problems. I thought I would document the problems I encountered incase you run into them yourself.

First, make a copy of your "httpd.conf" file for editing and making modifications. Do not use Microsoft Word for editing the source text file. I tried doing this and even told Word to save the file in text format but it did not put it in a plain ASCII text format. I believe it put it in a rich text format instead. By using the "httpd -t" command with the terminal application I was able to do a syntax check of the "httpd.conf" file. Using the "more httpd.conf" command when in the "/private/etc/httpd" directory (location of the "httpd.conf" file) is useful in displaying the file in the terminal to make sure it is of good text format.

You need to also remember to uncomment (remove the # from the beginning of the line) two lines at the beginning of the "httpd.conf" file in order to load the modules needed for proxy serving. They are as follows:

LoadModule proxy_module libexec/httpd/libproxy.so

AddModule mod_proxy.c

The default proxy commands I found in my "httpd.conf" were slightly different from what is found above. In particular the "CacheRoot" line in my file is different. You also need to make sure to modify the "Allow from" line to show the IP address (or domain name address) of the computer that will be proxying your machine. I'm told that only one IP address is allowed per line. So if you are making a proxy server for a home network like myself, you will need to make multiple "Allow from" lines for each computer on your home network. Here's how my proxy section of the file looks after modication:

< IfModule mod_proxy.c >
ProxyRequests On

< Directory proxy:* >
Order deny,allow
Deny from all
Allow from 192.162.60.61
< /Directory >

#
# Enable/disable the handling of HTTP/1.1 "Via:" headers.
# ("Full" adds the server version; "Block" removes all outgoing Via: headers)
# Set to one of: Off | On | Full | Block
#
ProxyVia On

#
# To enable the cache as well, edit and uncomment the following lines:
# (no cacheing without CacheRoot)
#
CacheRoot "/private/var/run/proxy"
CacheSize 5
CacheGcInterval 4
CacheMaxExpire 24
CacheLastModifiedFactor 0.1
CacheDefaultExpire 1
# NoCache a_domain.com another_domain.edu joes.garage_sale.com

< /IfModule >

There are not actually spaces after or before the "<" and ">" operators, this is just done so that the statement will not be confused with HTML statements when displayed here.

Now that this is done simply go the Sharing System Preference panel in MacOS X and click on the start web sharing button. If you really screwed up your "httpd.conf" or saved it in a non-plain ASCII text format then Web Sharing will never actually start up and kind of hang while trying to start. If you've made it this far, there is just one more step.

Go to the other computers on your home network and setup proxying in your net apps. For example, in Netscape open the preferences and select "Proxies" in the advanced section and select "Manual Proxy Configuration." Now click on view and setup the proxies for HTTP, FTP, and Security (or SSL) using the IP address (or domain name address) of the computer you setup proxying on. Set the port to 80 unless you modified this default port setting in the "httpd.conf" as well. As a note, this should allow all other computers on the network to access web content via the proxy server you have created whether they are a Windows or Mac computer.

The only problem I have had is being able to use mail applications and programs like AOL Instant Messager to use the proxy server for connections. If anyone has any suggestions on how to get these things to work via the MacOS X Apache proxy server please let me and the rest of us here know.

Thanks again everyone...
 
Back
Top