Skip to content

Instantly share code, notes, and snippets.

@TCNOco
Created August 20, 2022 11:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TCNOco/7b3fd8990d02bf9ac79c5d75abccdb4a to your computer and use it in GitHub Desktop.
Save TCNOco/7b3fd8990d02bf9ac79c5d75abccdb4a to your computer and use it in GitHub Desktop.
Block/troll all website scrapers with Nginx
# This is a little bit of fun you can use to troll some scraper bots, with more than just a 404 page.
# Especially useful if you don't have Wordpress, and are tired of bots scraping over and over
location ~* /wp- {
return 302 https://www.youtube.com/watch?v=dQw4w9WgXcQ;
}
# Else, for a deny:
location ~* /wp- {
deny all;
}
# And for more fun, if you have wildcards enabled in DNS (So all subdomains point to your website), you can define websites manually, of course, and then have a redirect for those who go snooping.
# For example, https://hub.tcno.co exists and has a server record. For https://test.tcno.co/ you'll come across the default server (assuming there isn't another "default_server" already defined, and see the Nginx welcome page...
# Why not redirect somewhere more fun?
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 302 https://www.youtube.com/watch?v=dQw4w9WgXcQ;
}
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
ssl_certificate /etc/letsencrypt/live/YOUR-WILDCARD-SUBDOMAIN-SSL-CERT-HERE/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/YOUR-WILDCARD-SUBDOMAIN-SSL-CERT-HERE/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
server_name _;
return 302 https://www.youtube.com/watch?v=dQw4w9WgXcQ;
}
# Obviously the last one you can use return 302 https://tcno.co, or your real landing page to redirect people to where they 'should be'.
# This is obviously just for fun, and to screw with people who want to do some snooping.
# Of course, this is for fun. Don't take it too seriously.
# Though, you may get something from it :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment