Host your own Tor hidden service!
A super simple guide to spinning up a Tor hidden service. [tl;dr]
Ubuntu 20.04 LTS was used for the making of this guide.
you can install Tor using the following command
sudo apt install torbrowser-launcherThis package includes everything you need to run a Tor hidden service and to browse them.
If you're running this on a server and don't need the browser, you can install the standalone Tor daemon using the following command
sudo apt install toryou need to look for a torrc file which will most probably be in the /etc/tor directory. open it in an editor. you'll need to use sudo because it is a protected file.
#nano
sudo nano /etc/tor/torrc
#vim
sudo vim /etc/tor/torrcLook for the following lines.
############### This section is just for location-hidden services ###
## Once you have configured a hidden service, you can look at the
## contents of the file ".../hidden_service/hostname" for the address
## to tell people.
##
## HiddenServicePort x y:z says to redirect requests on port x to the
## address y:z.
#HiddenServiceDir /var/lib/tor/hidden_service/
#HiddenServicePort 80 127.0.0.1:80
you need to uncomment these lines and update accordingly
HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServicePort 80 127.0.0.1:PORT
Where PORT is the port number on which your application is accessible on the localhost.
For this guide, we're going to use a simple directory listing server.
If you have NodeJS installed, you can use the following command to start the server.
npx serve -l 5000Alternatively, if you have Python 3 installed, you can use the following command to start a python http server.
python3 -m http.server --bind 127.0.0.1 5000So our torrc file now looks like following
HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServicePort 80 127.0.0.1:5000
Now that everything is configured, you can start the Tor service by using the following command.
sudo torUpon starting tor for the first time, a new .onion address will be generated for you. you can get the address using the following command
sudo cat /var/lib/tor/hidden_service/hostnameIf you've changed the HiddenServiceDir setting in the torrc file, you can find the hostname in <HiddenServiceDir>/hostname file.
Anyone can now visit this address using Tor Browser to use your website.
This is a pretty short guide though. But anyways...
Install Tor
sudo apt install torConfig
echo -e "HiddenServiceDir /var/lib/tor/hidden_service/\nHiddenServicePort 80 127.0.0.1:5000" | sudo tee -a /etc/tor/torrcStart server
# NodeJS
npx serve -l 5000
# Python 3
python3 -m http.server --bind 127.0.0.1 5000Start Tor
sudo torGet hostname
sudo cat /var/lib/tor/hidden_service/hostnameAnd just like that, your web app is deployed on Tor. Now get off my lawn ι(`ロ´)ノ