This entry will show you, how to configure onion domain for your website. This will allow access to your website through the Tor protocol, using .onion domain. Facebook did something similar. I decided that my site will also be available on the Tor network. You can reach 0ut3r Space using it standard address which is http://0ut3r.space and now also using
http://reycdxyc24gf7jrnwutzdn3smmweizedy7uojsa7ols6sflwu25ijoyd.onion/
To open onion address you need to use Tor Browser.
Installing Tor
Edit sources.list:
1 | sudo nano /etc/apt/sources.list |
and add Tor repository (here you can find list of actual Tor repositories)
1 | deb https://deb.torproject.org/torproject.org stretch main |
Add repository keys:
1 | gpg2 --recv A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 |
Update package list and install Tor:
1 | sudo apt update && sudo apt install tor |
Tor configuration
Edit Tor configuration file to look like this (don’t forget to open HiddenService port on your firewall, in below example it is set to 8123):
1 | SocksPort 9050 |
You can also use old version 2 or version 2 and 3 in same time but it is recommended to use next-gen onions version 3.
Now restart Tor:
1 | sudo service tor restart |
In folder /var/lib/tor/hidden_service/
you can find your onion domain private key.
Inside file called hostname
you will find your onion domain address.
Nginx Configuration
Next to your virtual host file create another one for onion configuration.
1 | server { |
Modify your hidden service port and root folder for your website. Server name should be set to your onion domain. By default, this file should look the same as the configuration of your page except the above changes, so don’t forget about php configuration and other setting you are using on your server.
Save this file and create link to activate this configuration.
1 | sudo ln -s /etc/nginx/sites-available/youronionconfiguration /etc/nginx/sites-enabled/youronionconfiguration |
Test Nginx configuration
1 | sudo nginx -t |
and if everything is ok restart web server
1 | sudo service nginx restart |
Now your website is visible in both networks. As standard domain in Internet and as onion domain in Tor network. You can find more about configuring Onion service in official documentation.
Onion Location
Since 8th of July, it is possible to inform your visitors, that your website have onion address. Please read more on the official Tor Project blog in post #MoreOnionsPorfavor: Onionize your website and take back the internet.
Whole process of adding Onion Location is described in documentation.
In short, you need to add header to your server configuration.
Example for Nginx.
Edit website conf:
1 | sudo nano /etc/nginx/conf.d/<your-website>.conf |
and add line:
1 | add_header Onion-Location http://<your-onion-address>.onion$request_uri; |
Example for Apache
1 | Header set Onion-Location "http://your-onion-address.onion%{REQUEST_URI}s" |
Thanks to that if someone visit your website using Tor Browser with standard domain, will be informed that you have onion domain too.
Here is example how it looks like for 0ut3r.space
Nice, right?