I have an application running on Apache on CentOS. It has internet facing IP address. I want it to accept only anonymous connections from Tor browser. How to do this?
Depending on your purpose, there are two possibilities.
You either have to create a hidden service:
- Install Tor.
- Install Apache (as you already have) and bind it to
Configure hidden service in your
HiddenServiceDir /var/lib/tor/hidden_service/ HiddenServicePort 80 127.0.0.1:80
and restart Tor. Tor then generates a new public/private keypair and a
hostnamebased on that public key. All these files can be found in the HiddenServiceDir specified.
Backup your private key if you would like to keep the
.onionaddress unchanged in the future.
Or you could do the exact opposite of blocking access from Tor exit nodes.
Inside the desired configuration section (
Order deny,allow Deny from all Include /etc/apache2/tor-ip.conf
tor-ip.conffrom dan.me.uk list of TOR exit nodes, but use
wget -q https://www.dan.me.uk/torlist/ -O - \ | sed 's/^/allow from /g' > /etc/apache2/tor-ip.conf; \ service apache2 reload
Only creating a hidden service makes your server anonymous, too. The other option only requires your users to use an anonymous Tor connection.