How to spoof a only a directory of a website (e.g. via DNS

Posted December 29, 2016 3.3k views

DNS Spoofing is considered…bad. But that’s only because people do not use it for good.

I am trying to block a directory of a website by spoofing it on my local DNS server. However, I do not want it to redirect. Here is an example of what I have done so far. The website shall remain unnamed for privacy.

http {
    server {
        listen       80;

        location / {
            proxy_set_header host $http_host;

        location = /blocked/blocked.json
        root /dns/;
        autoindex on;

The directory of the website that I want to block (examp; passes through the DNS and pulls up what it would without a DNS at all, however, the main directory of the website ( throws a 500 internal server error.

This is running on an Ubuntu server with DNSMasq (DNS is set up properly).

edited by asb

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer