Dnsmasq + Nginx = Detailed Block Page


New Member
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, which I like, but I don't always have a SSH session open to watch it.

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.

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

echo '<html>
        <title>Blocked !</title>
        <h1>  Advertisement</h1>
</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).

Staff online

Members online