Before you go, check out these stories!

Hackernoon logoSetting Up a Tor Hidden Service [A How-To Guide] by@arthtyagi

Setting Up a Tor Hidden Service [A How-To Guide]

Author profile picture

@arthtyagiArth Tyagi

17 year old developer working on stuff that intrigues me. founder and CEO, ArisVeam.

I'm gonna out on a limb here and assume that you know the basics of how a web server works when you clicked on the title of this post. Basic knowledge of vim would be helpful too.

For help, if you get stuck, look at the Note at the bottom of this post.

This tutorial is specifically aimed for Unix users but anyone can follow this in all honesty. Yeah, even the Windows users!👌🏻

Alright, so, first of all, you wanna make sure that you have a web server up and running. You can use Apache2 but for better security and anonymity, I'd recommend that you use Nginx. It's pretty cool :P

Step 1 - Setting up the Nginx server

To check for its installation, type

into the terminal. And head to
in your preferred web browser.

If you don't have it installed, you can go ahead and install it using

brew install nginx
on your macOS or
sudo apt-get install nginx
on your WSL or Linux distro with Debian packages.

Once you have it installed, run it using

and head to the
in your browser. If it shows something similar to:

Once you are sure that Nginx is installed and runs fine, move on to the next step.

Step 2 - Configuring the Nginx config file *( Optional )*

Let's say you are already hosting something on localhost:8080 and don't want to set up Nginx on that port, you'd want to change the Nginx config file in that case.

arthtyagi@MacBook-Pro ~ % cd /usr/local/etc/nginx
arthtyagi@MacBook-Pro ~ % vim nginx.conf

( Note: If you don't like how your vim is, check this vimconfig out. )

 84     #server {
 85     #    listen       8000;
 86     #    listen       somename:8080;
 87     #    server_name  somename  alias  another.alias;
 89     #    location / {
 90     #        root   html;
 91     #        index  index.html index.htm;
 92     #    }
 93     #}

Uncomment these lines to open port 8000 for Nginx and while you are at it, don't forget to comment out port 8080 lines cause you don't want Nginx listening on two ports, that just doesn't work.

Once you're satisfied with your configuration, move on to Step 3.

Step 3 - Serving static content

arthtyagi@MacBook-Pro ~ % cd /usr/local/var/www
arthtyagi@MacBook-Pro ~ % vim index.html

This opens the index.html file in vim, edit it however you want. Add CSS, put the files appropriately though. If an issue occurs while serving static content ( probably won't ), feel free to lookup Stackoverflow.

Now make sure your Nginx server is up and running and visit, `localhost:8080` in your browser.

Step 4 - Serving on the Dark Web as a .onion site

First, you wanna make sure that you have

installed on your system.

Type in

in your terminal, if it initiates a tor connection, you've got tor installed. Else, you might really wanna install it. Use
brew install tor
to install tor on your macOS.

For Debian/Ubuntu/WSL with Debian/Ubuntu refer to this. Once you have made sure it's installed, move on to Step 5.

Step 5 - Configuring the torrc

1. Head into the tor directory. For macOS, it's available here :

arthtyagi@MacBook-Pro ~ % cd /usr/local/etc/tor

2. If you list the files present, you'll find that there is a file named

present in the tor directory.

Now you'd want to change `

` to `
`. You can do that by simply opening the `torrc.sample` in vim and using the vim command,
:!mv torrc.sample torrc

3. Edit the torrc file using

vim torrc

Add these lines :

 HiddenServiceDir /usr/local/etc/tor/hidden_http_service/
 HiddenServicePort 80

Final Step: Run the Service

arthtyagi@MacBook-Pro ~ % tor 

Your site is serving over Tor relay now. But where?

arthtyagi@MacBookPro~% cat/usr/local/etc/tor/hidden_http_service/

You will see a .onion address, that's where your onion service is live at.

Additional Step: Read into these

Operational Security and Next Gen V3 options.


1. To stop the Nginx server, use

sudo nginx -s stop

2. To stop Tor, use

killall tor

3. To save and exit in vim, use


4. For a nice Vim reference, visit Vim Cheatsheet.

Either way, I'm glad you read this to the end ( hopefully lol ).


Join Hacker Noon

Create your free account to unlock your custom reading experience.