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:

  1. Install Tor.
  2. Install Apache (as you already have) and bind it to localhost by Listen
  3. Configure hidden service in your torrc:

    HiddenServiceDir /var/lib/tor/hidden_service/
    HiddenServicePort 80

    and restart Tor. Tor then generates a new public/private keypair and a .onion hostname based on that public key. All these files can be found in the HiddenServiceDir specified.

  4. Backup your private key if you would like to keep the .onion address unchanged in the future.

Or you could do the exact opposite of blocking access from Tor exit nodes.

  1. Inside the desired configuration section (<VirtualHost>, <Directory> etc.), add

    Order deny,allow
    Deny from all
    Include /etc/apache2/tor-ip.conf
  2. Create tor-ip.conf from dan.me.uk list of TOR exit nodes, but use allow instead of deny:

    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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.