explicitClick to confirm you are 18+

Tutorial - Tor and Nginx

museJul 1, 2018, 11:10:24 AM
thumb_up13thumb_downmore_vert

I demonstrated in another post how to host IPFS through a Tor Proxy. I also made an attempt to translate it to Vietnamese. In this post I will show you how to install Tor and Nginx. This is a more standard configuration than IPFS. You can use this configuration on a Vultr Virtual Private Server. The full script is here so you can run it without understanding any of it. You can install the whole thing quite easily by adding it to Vultr startup scripts, the only thing that requires typing and is a little bit hard to do is logging into the Vultr server with SSH and finding out what is your Onion domain name.

1. Outline
2. Setting up Nginx
3. Setting up Tor
4. Testing

1. Outline

The diagram below roughly demonstrates what happens with this server configuration. The client uses the Tor Browser to connect to the Onion server. It chooses several Tor Relay Nodes in between the client and the Tor Server. The Tor Server and the Nginx server are on the same computer, when the Tor server receives a request from the client, it passes the request to the Nginx server running on the same computer. The Nginx Server finds the resource requested and passes it back to the Tor Server, and then it goes back through the Tor Relay Nodes to the User with the Tor Browser.

2. Setting up Nginx

It is pretty easy to set up Nginx

Line 7-8 are variables to make it easy to adapt in the future. Line 7 conveniently sets a url that you will download and host from your Onion Server later. In this case, we are just downloading the torproject website and rehosting it.

Lines 10-12 are for installing nginx.

Line 14 makes a directory for hosting your files.

Line 16 copies the standard Nginx index.html and error files for hosting your website. Line 17 downloads the url defined in line 7 so you can host these files.

Line 19 edits the Nginx configuration file to tell Nginx to get the files from the web directory.

Lines 21-22 starts the nginx web server now and every time after boot.

3. Setting up Tor

I have explained setting up Tor in a previous tutorial mentioned in the introduction, so I will not include it here. Nginx is configured by default to listen to port 80, and Tor is configured by default to send messages to the same port, so they actually match up easily by default. The whole install script is linked to in the introduction of this blog post.

4. Testing

Copy the script from the URL in the introduction and add it to your startup scripts on Vultr.

Deploy the web server then log into it with a secure shell(I know some of you will not know how to do this). Type the command below, which will tell you your Onion address.

Copy this address and paste it into the Tor Browser and you should a page like the image below. This is hosting a page from the Tor website on your own server. To host your own files go into your directory /var/www and change the files there.