Hosting a Tor Hidden Service with an Onion Address on Linux

Aryan Dinakaran
DevOps.dev
Published in
3 min readNov 11, 2022

--

Photo by Jefferson Santos on Unsplash

What is tor hidden service

A tor hidden service is a service that allows users to anonymously publish their website without revealing their IP addresses. These services are hosted on the dark web with a .onion domain and can only be accessed using a special browser called tor.

The tor browser will hide your identity (IP address) and browsing activity by redirecting traffic through a series of different routers known as nodes. In this blog, we will learn how to host your own tor service or in simple words how to host a website on the Dark Web.

Let’s Begin

Firstly, let’s install the required packages, so type the command

sudo apt update && sudo apt upgrade

to check for updates and update your system if any. Next, we’ll install apache to host our index.html file.

sudo apt install apache2

finally, we’re going to install the tor services package to host our webpage on the dark web

sudo apt install tor

Now that we have everything installed let's go ahead and make a directory in /var/www/html/ by using mkdir, inside which we’ll be making an index.html file by using the touch command. Write some HTML code in the index.html and save it.

Once saved, head on to your browser and go to http://localhost:80/dirName. The URL will return something like this on your browser.

index.html file rendering in the browser

Note in this blog I have used a remote server in my local area network hence my URL looks different, but in your case, you are most probably hosting the HTML file in your local systems, so for you, the URL should be http://localhost:80/dirName.

Now that we have our website set up, let's go ahead and set up tor services. We’ll have to configure our tor service settings by editing /etc/tor/torrc. Uncomment the section which defines the host and port number of our tor services and save the file.

This is how the torrc file will look like

Use the following command in your terminal to restart tor service

sudo service tor restart

Finally, we have to get the onion URL of our tor service. We’ll use the cat command to get the URL of our tor service from the hostname file in the /var/lib/tor/.

sudo cat /var/lib/tor/hidden_service/hostname

Cools! Now that we have everything set up let's head on to the tor browser and access our tor hidden service. Copy the URL we got from the hostname file and paste it into tor browser’s URL bar. Voila, your website now lives on the dark web as well.

Preview of your website on the dark web

With that being said, we now have a functioning website that is hosted on the dark web. This website can be anonymously accessed by anyone using the Tor Browser. I hope you learned something new!

Happy Coding 👨‍💻!

--

--