2021-06-30 18:35:15 +00:00
<!DOCTYPE html>
< html lang = en >
< head >
2021-07-01 16:34:57 +00:00
< title > Mirror your site over Tor< / title >
2021-10-10 21:55:08 +00:00
<!-- # include file=".nav.html" -->
2021-06-30 18:35:15 +00:00
< / head >
< body >
2021-06-30 21:34:27 +00:00
< header > < h1 > Mirror Your Site Over Tor< / h1 > < / header >
2021-06-30 18:35:15 +00:00
< nav > < / nav >
< main >
2021-06-30 21:34:27 +00:00
< img class = titleimg src = "pix/tor.svg" alt = "Tor logo" >
2021-06-30 19:05:22 +00:00
< p >
2021-06-30 18:35:15 +00:00
Now that you have a website, why not offer it on a private alternative such as the onion network?
< / p >
< h2 > Setting up Tor< / h2 >
2021-07-01 11:14:21 +00:00
< h3 > Installing Tor< / h3 >
2021-07-01 16:34:57 +00:00
< p > Firstly we need to add the Tor repos to our system to get the latest version of Tor:< / p >
2021-07-01 11:14:21 +00:00
< pre > < code > apt install -y apt-transport-https gpg
echo "deb https://deb.torproject.org/torproject.org buster main
deb-src https://deb.torproject.org/torproject.org buster main" > /etc/apt/sources.list.d/tor.list< / code > < / pre >
2021-07-01 16:34:57 +00:00
< p > Then we need to add the gpg keys to our keyring:< / p >
2021-07-01 11:14:21 +00:00
< pre > < code > curl -s https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --import
gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | apt-key add -< / code > < / pre >
2021-07-01 16:34:57 +00:00
< p > Now update and install Tor:< / p >
2021-07-01 11:14:21 +00:00
< pre > < code > apt update
apt install tor deb.torproject.org-keyring< / code > < / pre >
< h3 > Enabling Tor< / h3 >
2021-06-30 18:35:15 +00:00
2021-07-01 16:34:57 +00:00
< p > Next edit the file < code > /etc/tor/torrc< / code > , uncommenting the following lines:< / p >
2021-07-01 11:14:21 +00:00
< pre > < code > HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServicePort 80 127.0.0.1:80< / code > < / pre >
2021-06-30 18:35:15 +00:00
< aside >
< h4 > Optional: Running multiple onion services< / h4 >
< p > If you want to forward multiple virtual ports for a single onion
service, just add more HiddenServicePort lines (replace the 80 with any unoccupied port).
< / p >
< p > If you want to run multiple onion services from the same Tor client, just add another
HiddenServiceDir line.< / p >
< / aside >
2021-07-01 16:34:57 +00:00
< p > Now start and enable Tor at boot:< / p >
2021-06-30 18:35:15 +00:00
< pre > < code > systemctl enable --now tor < / code > < / pre >
< p > If the next command outputs < q > active< / q > in green you're golden!< / p >
< pre > < code > systemctl status tor< / code > < / pre >
2021-07-01 16:34:57 +00:00
< p > Now your server is on the dark web. The following command will give you your onion address:< / p >
2021-06-30 18:35:15 +00:00
< pre > < code > cat /var/lib/tor/hidden_service/hostname< / code > < / pre >
< h2 > Adding the Nginx Config< / h2 >
< p >
From here, the steps are almost identical to setting up a normal website configuration file.
2021-07-01 16:34:57 +00:00
Follow the steps as if you were making a new website in the webserver
2021-06-30 19:47:19 +00:00
< a href = "nginx.html" > tutorial< / a > up until the server block of code. Instead, paste this:
2021-06-30 18:35:15 +00:00
< / p >
< pre > < code > server {
listen 127.0.0.1:80 ;
root /var/www/< strong > landchad< / strong > ;
index index.html ;
server_name < strong > your-onion-address< / strong > .onion ;
}< / code > < / pre >
< aside >
< h4 > Clarification< / h4 >
< p > Nginx will listen on port 80 for your < em > server's< / em > localhost.< / p >
< p > The < code > root< / code > line is the path to whichever website of yours you'd like to mirror.< / p >
< / aside >
< p >
2021-07-01 16:34:57 +00:00
Now we are almost done, all we have to do is enable the site and reload nginx which, is also covered in < a href = "nginx.html#enable" > the webserver tutorial< / a > .
2021-06-30 18:35:15 +00:00
< / p >
2021-07-01 11:14:21 +00:00
2021-08-19 11:42:28 +00:00
< h3 > Advertise your onion service< / h3 >
< p > You can add the Onion-Location header to your normal website to advertise your onion service to Tor users. On your regular site's nginx config, add the following line:< / p >
< pre > < code > server {
...
add_header Onion-Location http://< strong > your-onion-address< / strong > .onion$request_uri;
}< / code > < / pre >
< p > After doing this and reloading nginx, when visiting your regular site via Tor, you should see a ".onion available" button on the address bar, which should take you to the onion service.< / p >
2021-07-01 11:14:21 +00:00
< h3 > Update regularly!< / h3 >
< p > Make sure to update Tor on a regular basis by running:< / p >
< pre > < code > apt update
apt install tor< / code > < / pre >
2021-07-29 20:52:44 +00:00
< h4 > Note:< / h4 >
< p > You do < u > not< / u > need to run certbot for an ssl certificate. HTTP over tor is plenty secure!< / p >
< p > < strong > Contributor< / strong > - < a href = "https://tomfasano.co" target = "_blank" > tomfasano.co< / a > < / p >
2021-06-30 18:35:15 +00:00
< / main >
2021-10-10 21:31:21 +00:00
<!-- # include file=".footer.html" -->
2021-06-30 18:35:15 +00:00
< / body >
< / html >