Post

What is Tor , How to host your Website on Tor

What is Tor , How to host your Website on Tor

Tor is one of the most well-known tools for anonymous browsing. In this article I’ll explain where it came from, how it works under the hood, and — as a bonus — how you can publish your very own site on the onion network.

1. Origins of Tor

Onion routing was invented to separate identification from routing → anonymous routing. Note the wording: it gives you anonymous routing — not anonymity. The path you take is hidden, but what you send still has to be interpreted at the other end.

The concept was born in the mid-1990s at the US Naval Research Laboratory, where researchers designed a way to route traffic so that no single hop could link a user to their destination. Tor itself (the open-source implementation) was released publicly in 2002, and today it is run by a global network of volunteers.

2. Understanding Tor

2.1 Browsing the Internet the Regular Way

When you open a website the normal way, your request takes a straight, predictable path — and every hop along it can see where you’re headed.

You Wi-Fi Router ISP Website your computer home network Vodafone, Orange… web server 1 2 3
  1. First, your request goes through your Wi-Fi router.
  2. Your router is connected to your Internet Service Provider (ISP), such as Vodafone or Orange.
  3. Your ISP then connects you to the website you wish to visit.

In other words, your ISP knows exactly which websites you visit and when you visit them.

2.2 How a VPN Moves the Problem

A VPN inserts a single extra hop in the middle. Instead of telling your ISP “I’m going to website X”, you tell it “I’m going to a VPN server in another country” — a destination that is usually not blocked by your ISP. From there, the VPN fetches the page for you.

You ISP VPN server Website sees only traffic to the VPN a single point of trust IP · credit card · activity

A VPN simply moves the problem elsewhere: the ISP may no longer see your traffic, but the VPN operator replaces it as the single point of trust. Operators can collect personal data — your real IP address, your credit card info, and logs of your online activity.

2.3 Connecting Through Tor: Onion Routing

Tor works differently: it builds a path through three independent relays and encrypts your data three times — like wrapping a letter in three envelopes. Every relay peels off exactly one layer and passes the rest along. Hop 1 knows your IP but not your destination; hop 3 knows the destination but not your IP. No single relay ever sees both ends.

TOR CIRCUIT — three volunteer relays 3 layers 2 layers 1 layer plaintext You Guard Middle Exit Website peels layer 3 peels layer 2 peels layer 1

When using Tor, your traffic is routed through 3 servers instead of 1, as with a VPN. Your traffic is encrypted 3 times, Tor servers are run by volunteers instead of private corporations, and Tor is decentralized — VPNs aren’t.

That peeling of each layer is exactly why the technique is called onion routing.

3. A Deeper Look Inside Tor

3.1 Relays & the Tor Circuit

Tor relays are volunteer-run servers that simply relay (pass) encrypted traffic from one node to the next. Once you pick a circuit, it’s reused for a while — then Tor builds a new one with fresh relays.

Tor is not a peer-to-peer (P2P) program like BitTorrent. Your client talks only to the three relays of its circuit — it doesn’t exchange data with random users.

A TOR CIRCUIT — one three-hop route 1st hop 2nd hop 3rd hop Entry / Guard Middle Exit
  • Entry / Guard relay — the first hop; it knows who you are but not where your traffic is going. It stays in your circuit for a long time, which helps detect malicious relays trying to join the network.
  • Middle relay — an anonymous middleman; it knows neither you nor your destination.
  • Exit relay — the last hop; it decrypts the final layer and talks to the target website, so it does see the destination.

The full three-hop route is called a Tor circuit, and Tor refreshes it periodically to make traffic analysis harder.

3.2 Bridges & Pluggable Transports

Governments and ISPs that want to block Tor don’t have to block the whole network — they only need to block the public IP addresses of the guard relays. Bridges are a workaround: relays that are not publicly listed, so censors don’t know their addresses.

1
User → Bridge → Tor network → Website
You Bridge Tor network Website a secret, unlisted relay

You can even request a private bridge address that’s given only to you — far harder to block than one that’s published.

To make bridges even harder to spot, most of them use what are called pluggable transports. Anyone surveilling your internet traffic might be able to recognize patterns that indicate you’re connecting to Tor and block your access to it (though they won’t know what you intended to visit over Tor). Pluggable transports prevent this by transforming Tor’s traffic to look like something else entirely. The main types on Tor are:

  1. obfs2 — makes your Tor traffic look like random data.
  2. meek — connects you to the Tor network through a big cloud provider.
  3. snowflake — routes your connection through Snowflake proxies to make it look like you’re placing a video call.
  4. webTunnel — mimics encrypted web traffic (HTTPS).

4. Host Your Own Website on the Onion Network

Now for the fun part. Hosting an onion site needs exactly two ingredients: a web server that speaks HTTP (Apache or Nginx) and a Tor service configured as a hidden service. Nginx only ever listens on 127.0.0.1:80 — the Tor process forwards outside traffic to it.

4.1 Install the Requirements

I’ll use Nginx and Tor. Install Tor in your terminal:

1
2
3
4
sudo apt install tor -y          # Ubuntu / Debian
sudo dnf install tor -y          # Fedora
sudo systemctl start tor         # start the Tor service
sudo systemctl enable tor        # run Tor automatically on boot

Install Nginx:

1
2
3
4
sudo apt install nginx -y        # Ubuntu / Debian
sudo dnf install nginx -y        # Fedora
sudo systemctl start nginx       # start the Nginx service
sudo systemctl enable nginx      # run Nginx automatically on boot

To make sure everything was installed successfully, check both services:

Checking the Tor service status

Checking the Nginx service status

You can also test Nginx directly: curl http://127.0.0.1:80 — if you see the welcome page, the installation was a success.

4.2 Configure the Hidden Service

Nginx serves files from /var/www/html/, so copy your website files into that folder, then point Tor at it:

  1. Edit the torrc file:
    • sudo nano /etc/tor/torrc
  2. Scroll all the way to the bottom and add these two lines:
    1
    2
    
    HiddenServiceDir /var/lib/tor/my_onion_site/
    HiddenServicePort 80 127.0.0.1:80
    
  3. Restart the Tor service: sudo systemctl restart tor
  4. Get your .onion address: sudo cat /var/lib/tor/my_onion_site/hostname
  5. You should see a link like efknfenfwineifnweifnew.onion — that’s your website’s new address.
  6. Open the Tor Browser and visit your address.

Visiting the newly created .onion site

Here’s the whole architecture in one picture:

Tor Browser visits your .onion address your onion address (kept inside the Tor network) Your server (Ubuntu / Debian / Fedora) HTTP 127.0.0.1:80 Nginx :80 serves /var/www/html Tor hidden service onion key + hostname /var/lib/tor/my_onion_site/hostname

Unlike a normal website, an onion service doesn’t need a public IP address — it’s reachable only through the Tor network, which also keeps your server’s real location hidden.

Wrapping Up

That’s the whole picture: Tor separates who you are from where you’re going by peeling layers of encryption across a three-relay circuit, and with two simple config lines you can put any Nginx site behind a .onion address. Whether you want to expose a service without revealing your location, or you just want to experiment, hosting an onion service is a fun and instructive exercise.

This post is licensed under CC BY 4.0 by the author.

Trending Tags