Skip to content

Instantly share code, notes, and snippets.

@smokeev-dev
Created August 29, 2020 10:07
Show Gist options
  • Select an option

  • Save smokeev-dev/66a880bba4ad605430fbc1d1706349d5 to your computer and use it in GitHub Desktop.

Select an option

Save smokeev-dev/66a880bba4ad605430fbc1d1706349d5 to your computer and use it in GitHub Desktop.
How To Block Tor Exit-Nodes with Nginx (GeoIP)
#!/bin/sh
# Download a list of exit-nodes
wget -qO- https://check.torproject.org/torbulkexitlist | sort | awk '{print "" $1 " 1;"}' > /tmp/tor_exit_list.txt
# Prepare a geoip config
echo -e "geo \$isTor {\ndefault 0; \n$(cat /tmp/tor_exit_list.txt) \n}" > /etc/nginx/conf.d/deny-geoip-tor.conf
## Add to virtual host
# location / {
# if ($isTor) {
# return 403;
# }
# try_files $uri $uri/ =404;
# }
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment