Dnsmasq + Nginx = Detailed Block Page

Seaner992

New Member
Credits
0
I would like dnsmasq / nginx (doesn't have to be nginx) to direct blocked domains to a basic page showing the reason a domain was blocked. Just a single word is good enough. I have Dnamsq setup like below. I have 26 categories all together. When I watch the log file it tells me /etc/block/ads ads.com is 0.0.0.0, which I like, but I don't always have a SSH session open to watch it.

Code:
........
addn-hosts=/etc/block/ads
addn-hosts=/etc/block/bloat
addn-hosts=/etc/block/chat
........
I had an idea to do something like below, but it does not work, since Dnsmasq does not re-direct one domain to another. Example ads.block ads.com in /etc/block/ads errors out.

Bash:
echo "address=/.block/192.168.1.3" > /etc/dnsmasq.d/info

echo '<html>
    <head>
        <title>Blocked !</title>
    </head>
    <body>
        <h1>  Advertisement</h1>
    </body>
</html>' > /var/www/ads.html

cat /var/www/ads.html > /var/www/malware.html
sed -i "s/\bAdvertisement\b/Malware/Ig" /var/www/malware.html

echo 'user www-data www-data;
worker_processes 4;
error_log off;
pid        /var/run/nginx.pid;
events { worker_connections 1024; }
http {

server {
     listen 80;
     server_name ads.block;
     root /var/www/;
     index ads.html;
}
server {
     listen 80;
     server_name malware.block;
     root /var/www/;
     index malware.html;
}

}' > /etc/nginx/nginx.conf
service nginx restart
Any thoughts or ideas on how to do this? I'm not sure if this is even possible without using Squid or some form of proxy. (Prefer not to do that).
 




Members online


Top