Hosting your own ONION site
Hosting your own .onion site on the Tor network is a powerful way to offer anonymous, censorship-resistant content. Here’s a detailed step-by-step guide to setting up a hidden service (a .onion site) using Tor on a Linux system like Ubuntu. This guide assumes you’re using a VPS or local server.
🌐 What is a .onion Site?
A .onion address is a website hosted as a Tor hidden service. Only accessible via the Tor browser, it hides both the identity of the host and the user, offering strong anonymity.
✅ Prerequisites
-
A server (local or remote with SSH access).
-
A domain name isn’t needed; the Tor network provides the
.onionaddress. -
A basic web server (like Apache or Nginx).
-
Tor installed.
📦 Step 1: Install Tor
Install Tor from your system’s package manager:
Check it’s running:
🛠️ Step 2: Set Up a Web Server
Install a basic web server, like Apache:
Put your HTML content in /var/www/html/index.html.
Test by visiting http://localhost or your server’s IP — you should see your webpage.
🔐 Step 3: Configure the Hidden Service
Edit the Tor config file:
Add the following at the end:
Explanation:
-
HiddenServiceDir is where Tor stores keys and your .onion address.
-
HiddenServicePort maps port 80 of the hidden service to localhost’s port 80 (your web server).
Save and exit, then restart Tor:
🔍 Step 4: Get Your .onion Address
After restarting Tor, run:
You’ll see something like:
That’s your new .onion domain!
🔒 Step 5: Secure the Setup (Optional but Recommended)
-
Use a firewall to only allow connections on port 22 (SSH) and 80 (HTTP).
-
Keep Tor and Apache updated.
-
Consider using HTTPS inside Tor (yes, even on .onion) with a self-signed cert or Let’s Encrypt (if reachable).
🧪 Step 6: Test in Tor Browser
Open the Tor Browser and visit your .onion URL.
You should see your website!
🚀 Advanced Tips
-
You can host multiple .onion services by duplicating the HiddenService* lines with different ports/directories.
-
To rotate your onion address, delete
/var/lib/tor/hidden_service/and restart Tor — but you’ll lose the old address. -
For persistent identity, back up the private key in that directory (
private_keyfile).
⚠️ Legal & Ethical Note
Running a .onion site is legal in most countries if used for legal purposes. Always check local laws and avoid hosting anything illegal or malicious.
