TOR Server Installation in a Docker Container on Your VPS

Version: 25.5.18

In this tutorial, I will show you how to install a Tor server as a middle relay on a VPS. At the same time, you’ll set up a proxy server that allows you to use the Tor connection in a web browser (e.g., Firefox) to browse the internet anonymously. This way, your own browsing behavior is mixed with the traffic passing through the server.

🖥️ What do you need?
1. A VPS server with a public IPv4 address on the internet and enough free traffic per month (up to 2,5TB in our configuration)
2. Linux and SSH knowledge (terminal)
3. Docker and Docker-Compose installed (an installation script will also be shown)
4. The conviction to take action against censorship and restrictions on freedom on the internet 😊

We start and log in to the server:

Go to your Docker project folder, which in my case is located under /home/.

A folder named “tor” is created:

And changed into this:

🐳 If you don’t have Docker and Docker-Compose installed yet, here are some quick installation instructions. You can skip them if you like: First, install Docker by creating a file named “install.sh” in the /home/tor/ directory:

The following content is added to the file (Thanks to Patrick Asmus: https://git.techniverse.net/scriptos/public-linux-docker-installer)

Then run the file:

After completing the script, Docker and Docker-Compose are installed.

📁 Now we want to focus on the Tor server and create the following file in the /home/tor folder:

Paste the following content into the file and save it – the current Tor version 0.4.8.16 is used:

A new file is created:

This file ensures that Privoxy (our proxy server through which you can later access Tor via port 8118) and NYX only start after the Tor server has started:

The next file you create:

The following content goes here:

Of course, you’ll also need to change your relay’s nickname and contact email address accordingly. In our example, the Tor relay is only running as an IPv4 host, which is easier to implement. A new file follows:

This is the configuration file of our proxy server:

🚀 After you have created this file, you can build your own Docker image (everything will be saved and executed in the path /home/tor/):

You’ve now created your own Docker container with Tor Privoxy. You can verify this with the “docker images” command. The corresponding container should now appear here:

⚙️ Create the appropriate Docker-Compose.yml to start the container properly and safely:

The file is saved in the /home/tor folder with the following content:

Now you’ve completed all the steps to run a Tor server as a middle node on our VPS server. You can now start the container in the background:

You can view log files with

If you find “100%” in the logs, you’ve done everything correctly:

It is also important that ports 9001 and 9030 are accessible from the Internet and are open in the firewall.

Cauction: Only Allow Connections from your private IP to Port 8118 or block it. Thats the proxy-server function.

🔍 There is also the following function test for the proxy server:

A confirmation should appear here that a connection via TOR was possible.

✅ What have you achieved in the tutorial?

  • The latest version of TOR runs in a Docker container on the VPS server.
  • Privoxy and NYX are installed
  • Fingerprints and RSA Keys are saved in the “tor” directory outside the container
  • The Tor server is publicly accessible via TCP ports 9001 and 9030.
  • The proxy server that uses Tor is accessible via IP:8118 and can thus be specified as a proxy in the browser, for example (Cauction: Port 8118 only for your IP in the firewall settings of your vps)
  • You are actively committed to freedom on the Internet 😊

You can watch statistic via nyx with:

Leave the Statistic-Page with STRG+C and then type “exit”.

On the following page you can also retrieve information about your own Tor Relay:

https://metrics.torproject.org/rs.html


bc1q8dxp9mlt3mkvaklu2vn8j6jteqyv53kschc90v

Lightning: itsc@strike.me

Leave a Reply

Your email address will not be published. Required fields are marked *