Running Nextcloud as a hidden service (Tor)

I have created a small tutorial, where you can see how to run a Nextcloud and expose it as a tor hidden service and https at the same time.

I assume you are using Nextcloud installed on a Debian 9 virtual machine using Docker with docker-compose (see this link to instal it) and it works at cloud.example.com.

  • modify the file docker/.examples/docker-compose/with-nginx-proxy/postgres/apache/docker-compose.yml and add it two lines in the app section
    ports :
     - 8080:80
    
  • restart the docker container sudo docker-compose restart app
  • install tor : sudo apt-get install tor
    • verify tor runs correctly : sudo apt-get install torsocks curl and run torify curl http://expyuzz4wqqyqhjn.onion/ (Note : the onion link used is the torprojet home). It will show the html source.
  • modify /etc/tor/torrc and add
   HiddenServiceDir /var/lib/tor
   HiddenServicePort 80 127.0.0.1:8080
  • Note : Here we set the directory /var/lib/tor as the place where tor will put its file, you can chose another place.
    • Warning : the chosen place has to be owned by the user running tor (on default the user is debian-tor which owns /var/lib/tor if you want to change it run chown 700 name/of/the/directory/).
  • restart tor : sudo systemctl restart tor
  • copy paste the content of /var/lib/tor/hostname in your Tor Browser.
  • you should see an error message showing the following
    • copy the link location found in the error message and paste it into a regular browser and replace the onion part of the url with cloud.example.com.
    • confirm the .onion to be a trusted domain.
      Screenshot-2018-4-10 Admin - Nextcloud
    • in the Tor Browser, refresh and you should be able to log in.

That’s it ! Your Nextcloud should be online.

5 Likes