Even if you have no interest in serving web pages from your new OS X box, there's at least one feature of Apache (the built-in web server) that you might want to put to use - the proxy server.
A proxy server is nothing more than a server which sits between a client (such as a web browser) and a real server (such as a web host). It intercepts all requests sent by the client and decides if it can handle the request itself. If it cannot, it then passes the request on to the real server.
Why might you find this useful? There are two primary reasons. First, if you're a parent, you can use the proxy server to control which sites your kids can and cannot have access to. This may make you feel slightly more comfortable leaving them alone in front of the machine ... although any child with some level of net experience will be able to find ways to get what they wanted anyway.
Since the proxy will block sites that you specify, you can also use it to block ad servers such as www.doubleclick.net (and there goes any chance of ever having advertisers on this site ... want to get blacklisted ... just explain how to block ad servers! ;-)
The second usage is for caching web content locally. If you have a connection that's shared between multiple computers, you can use the proxy to store pages locally. That way, if you browse cnn.com and your spouse visits the site 30 seconds later from another machine, they will get a locally cached page which will be served very quickly.
Read the rest of this article if you'd like instructions on setting up Apache's proxy server.
The first step is to make sure your web server is stopped. You can do this through the System Preferences -> Network -> Services tab, or via the terminal. Since we're going to do the rest of this in a terminal session, you might as well start there. Open a terminal, and login as root ("su" and enter your password). Then type
apachectl stopThis will stop the webserver.
cd /Library/WebServer/ConfigurationNote that a backup file may already exist; you can use a new name if you'd like to keep everything intact.
cp apache.conf apache.bak
#LoadModule digest_module /System/Library/Apache/Modules/mod_digest.soRemove the comment ("#") from the second line.
#LoadModule proxy_module /System/Library/Apache/Modules/libproxy.so
#LoadModule cern_meta_module /System/Library/Apache/Modules/mod_cern_meta.so
#AddModule mod_digest.cAgain, remove the comment mark from the second line.
#AddModule mod_proxy.c
#AddModule mod_cern_meta.c
# Proxy Server directives. Uncomment the following lines toUncomment all the lines that are code (not comments). When you are done, it should look like this:
# enable the proxy server:
# Proxy Server directives. Uncomment the following lines toNotice two small things. First, Deny from all is left commented out -- otherwise, you wouldn't be able to browse the web at all! Second, you need to enter the IP numbers that you will allow to use the proxy server in the Allow from line. If you have more than one, enter them separated by a space.
# enable the proxy server:
#
<IfModule mod_proxy.c>
ProxyRequests On
<Directory proxy:*>
Order deny,allow
#Deny from all
Allow from .your_domain.com
#NOTE: Replace '.your_domain.com' with your IP number(s)!
</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 "/Library/WebServer/ProxyCache"
CacheSize 5
CacheGcInterval 4
CacheMaxExpire 24
CacheLastModifiedFactor 0.1
CacheDefaultExpire 1
NoCache a_domain.com another_domain.edu joes.garage_sale.com
</IfModule>
# End of proxy directives.
ProxyBlock playboy.com penthouse.com adserver.ugo.comAny sites listed will be blocked from browsing, and return errors when called from within pages, as you can see here:
apachectl startRemember to then disconnect from your root editing session!
Mac OS X Hints
http://hints.macworld.com/article.php?story=20010117003458918