If you're fed up with anoying adverts flashing away on web pages that you are trying to read, the following technique can be used to replace them with some plain text, served locally, so that it also saves bandwidth.
Essentially this consistis of:
Create directory /var/www/blocked.
# cd /var/www # mkdir blocked
Create index.html inside this directory as follows.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Advert blocked by stevesearle.com</title>
</head>
<body>
<h1>
Blocked!
</h1>
<p>
Advert blocked by stevesearle.com
</p>
</body>
</html>
Add the following to /etc/httpd/conf/httpd.conf.<\p>
...
NameVirtualHost blocked
<VirtualHost blocked>
ServerAdmin webmaster@stevesearle.com
DocumentRoot /var/www/blocked
ServerName blocked.stevesearle.com
ErrorLog logs/blocked.stevesearle.com-error_log
CustomLog logs/blocked.stevesearle.com-access_log common
ScriptAlias /cgi-bin/ /var/www/blocked/cgi-bin/
Options ExecCGI Includes
<Directory "/var/www/blocked">
AllowOverride All
Options Includes ExecCGI FollowSymlinks
Order allow,deny
Allow from all
</Directory>
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
AddHandler server-parsed .shtml .html
</VirtualHost>
Set up a rewrite rule for all requests to this domain to be redirectected to index.html. Create /var/www/blocked/.htaccess as follows.
RewriteEngine on RewriteRule ^.*$ index.html
Download a list of advert domamains. This should be saved as /var/named/chroot/etc/ads.list. Then add the following to /var/named/chroot/etc/named.conf.
... include "/etc/ads.list";
Create /var/named/chroot/var/named/pz/null.zone.file as follows.
$TTL 3D
@ IN SOA magpie.stevesearle.com. steve.stevesearle.com. (
200706171 ; Serial
8H ; Refresh
2H ; Retry
4W ; Expire
1D) ; Minimum TTL
NS magpie.stevesearle.com.
TXT "Steve Searle's local ad blocking zone"
A 127.0.0.1
* IN A 192.168.126.51
Restart BIND, and any requests for any of the domains listed in the ads.list will bne redirected to the local page you have created, saving bandwidth and often being far less distracting when viewing web pages.
# service named restart