To host a website on Tor, you need to set up an onion service on a machine running Tor and a local web server. The official Tor Project setup guide is at https://community.torproject.org/onion-services/setup/. You configure your torrc file by adding two lines: HiddenServiceDir (directory for keys) and HiddenServicePort (virtual port and local redirect). For example, HiddenServicePort redirects traffic from port 80 of your onion service to 127.0.0.1:80 where your web server listens. After restarting Tor, the hostname file in your HiddenServiceDir contains your new .onion address. Keep your onion service keys private—if they leak, anyone can impersonate your site. Host on a Tor client rather than a relay, since relay properties are publicly visible.
What You Need to Know Before Hosting a Tor Onion Site
Onion services are services that can only be accessed over Tor and give users all the security of HTTPS with the added privacy benefits of Tor Browser. Your site becomes reachable only through the Tor network, not the regular internet.
You should host onion services on a Tor client rather than a Tor relay, since relay uptime and other properties are publicly visible. Running your service on a relay exposes operational details that could compromise your privacy.
Basic requirements include:
A machine running Tor
A local web server (Apache, Nginx, or similar)
Access to the torrc configuration file
You don't need a domain registrar or public IP address. Tor generates your .onion address automatically when you configure the service.
Configuring Your Tor Onion Service
To set up a Tor onion service, you need to add two lines to your torrc file: HiddenServiceDir specifying the directory for information and cryptographic keys, and HiddenServicePort specifying the virtual port and local redirect address.
Open your torrc file and add these lines:
HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServicePort 80 127.0.0.1:80
The HiddenServicePort configuration redirects incoming traffic to port 80 of your onion service to 127.0.0.1:80 where the local web server listens. If your web server runs on a different port, adjust the second number. For example, HiddenServicePort 80 127.0.0.1:8080 redirects onion traffic to a local server on port 8080.
After saving the torrc file, restart Tor. The hostname file in your HiddenServiceDir directory contains the hostname for your new onion v3 service, while other files contain your onion service keys that must be kept private.
You can verify your service is running by visiting the .onion address in Tor Browser. If you see your web server's content, the configuration succeeded.
Securing Your Onion Service Keys
The HiddenServiceDir contains your onion service keys which must be kept private. These cryptographic keys prove ownership of your .onion address.
If your onion service keys leak, other people can impersonate your onion service, making it compromised, useless, and dangerous to visit. An attacker with your keys can redirect visitors to a malicious copy of your site.
Protect your keys by:
Setting strict file permissions on the HiddenServiceDir
Excluding the directory from backups that might be stored insecurely
Never copying keys to untrusted machines
Using encryption on the host machine
A best practice to avoid leaking an onion service to a local network is to run onion services over Unix sockets instead of a TCP socket. This prevents the web server from binding to a network interface where other machines could access it. Configure your web server to listen on a Unix socket, then point HiddenServicePort to that socket path instead of an IP address.
SSL/TLS Certificates for Onion Services
As of August 2024, there is currently no consensus on which certificate approach fits best for onion service setups. The Tor community continues to evaluate whether onion services should use traditional SSL/TLS certificates.
Onion services already provide end-to-end encryption through the Tor protocol itself. Adding HTTPS on top provides defense in depth but introduces complexity around certificate validation for .onion domains. Monitor Tor Project documentation for evolving best practices in this area.
Frequently Asked Questions
How much does it cost to host a website in Tor?
Hosting an onion service itself is free. You only need a machine running Tor and a web server. If you use your own hardware, there are no recurring costs beyond electricity and internet access.
Can I use a custom .onion domain name?
The hostname file in your HiddenServiceDir directory contains the hostname for your new onion v3 service. You cannot choose an arbitrary address because it is derived from your service's cryptographic keys. However, you can generate multiple key pairs until you find an address with a desired prefix using specialized tools.
Is Tor a dark web?
Tor is a network and browser that enables anonymous communication. The "dark web" refers to content accessible only through anonymizing networks like Tor. Tor itself is a tool; the dark web is a subset of content hosted as onion services. Many onion services host legal content such as news sites, forums, and privacy-focused services. For more details, see Tor Sites Dark Web: Understanding the Difference.
Can FBI track Tor Browser?
Tor routes traffic through multiple relays to provide anonymity. However, operational security mistakes, browser vulnerabilities, or correlation attacks can potentially compromise anonymity. Maintaining good operational security—such as not mixing Tor and non-Tor activity, keeping software updated, and avoiding personally identifying information—is essential when using Tor.
Is it legal to go on Tor?
Using Tor to access illegal content or conduct illegal activities remains illegal regardless of the tool used. Check local laws in your jurisdiction before hosting or accessing onion services.
Is Tor 100% untraceable?
Tor significantly increases the difficulty of tracing users, but no system guarantees absolute anonymity. Sophisticated adversaries with resources to monitor large portions of the network or exploit software vulnerabilities may be able to correlate traffic. Users should combine Tor with other security practices and understand that anonymity depends on both the network and individual behavior.
Q&A
- How much does it cost to host a website in Tor?
Hosting an onion service itself is free—you only need a machine running Tor and a local web server. If you use your own hardware, there are no recurring costs beyond electricity and internet access.
- Can I use a custom .onion domain name?
The hostname file in your HiddenServiceDir directory contains the hostname for your new onion v3 service. You cannot choose an arbitrary address because it is derived from your service's cryptographic keys, but you can generate multiple key pairs until you find an address with a desired prefix using specialized tools.
Where to look next
These services are useful starting points for further research. Tools & services.