Apache isn't just the planet's most popular Web server - it'salso one heck of a proxy server. This article explores the process ofinstalling and configuring Apache to act as a proxy server for yournetwork, demonstrating how it can be used to cache frequently-accessedWeb sites, log Internet access and block offensive domains, in additionto serving up Web content. Talk about getting two servers for the priceof one!
The ability to have all HTTP requests directed outside the network going through a single proxy, which is completely under your control, opens up some interesting possibilities. One of the most common ones involves using the proxy to filter out and reject requests for certain "bad" sites. Here's an example, which uses the very powerful ProxyBlock directive to reject all requests for the Playboy Web site.
ProxyBlock .playboy.com
You can specify multiple sites by separating them with
spaces.
ProxyBlock .playboy.com .badboy.com
You can block all sites in one swell foop with
ProxyBlock *
Obviously, this is kinda pointless, especially after all the
trouble you've gone to to set up the proxy in the first place - but feel free to try it, if only for the experience.
Any attempt to access one of these blocked sites will fail, with Apache returning a default error page to the client. Here's what it looks like:
Obviously, you can customize this page - simply specify the location of a different error page for all HTTP 403 errors, via the ErrorDocument directive.
ErrorDocument 403 /error403.html
Here's an example of a custom error page, specified using the
technique above: