Introduction:
Tor Hosting, also known as a Hidden Service, allows you to host websites or services on the Tor network, providing anonymity and enhanced privacy. In this guide, we will walk you through the process of setting up Tor Hosting on an Ubuntu 22.04 server using Nginx as a web server. Please note that this is a general guide, and additional configurations and security measures may be necessary depending on your specific requirements.
Prerequisites:
- An Ubuntu 22.04 server
- Basic knowledge of the Linux command line
- Administrative access to your server
Step 1: Server Preparation
Ensure that your Ubuntu 22.04 server is up to date by running the following commands:
sudo apt update
sudo apt upgrade
Step 2: Installing Nginx
Nginx will serve as the web server for your Tor Hidden Service. Install Nginx with the following command:
sudo apt install nginx
Start and enable Nginx to run on system startup:
sudo systemctl start nginx
sudo systemctl enable nginx
Step 3: Nginx Configuration
Create an Nginx configuration file for your Hidden Service. Replace yourdomain.onion
with your desired .onion address and adjust the proxy port as needed:
sudo nano /etc/nginx/sites-available/tor
server {
listen 127.0.0.1:80;
server_name yourdomain.onion;
location / {
proxy_pass http://localhost:8080; # Adjust the port where your application is running
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
Enable the configuration by creating a symbolic link:
sudo ln -s /etc/nginx/sites-available/tor /etc/nginx/sites-enabled/
Check the Nginx configuration for syntax errors:
sudo nginx -t
If there are no errors, restart Nginx:
sudo systemctl restart nginx
Step 4: Installing Tor
Install the Tor daemon on your server:
sudo apt install tor
Step 5: Tor Configuration
Edit the Tor configuration file:
sudo nano /etc/tor/torrc
Add the following lines at the end of the file to configure your Hidden Service. Replace 80 127.0.0.1:8080
with the port where your Nginx instance is listening:
HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServicePort 80 127.0.0.1:8080
Step 6: Creating the Hidden Service Directory
Create the directory for your Hidden Service and adjust the permissions:
sudo mkdir /var/lib/tor/hidden_service/
sudo chown debian-tor:debian-tor /var/lib/tor/hidden_service/
Step 7: Starting the Tor Service
Start the Tor service:
sudo systemctl start tor
Step 8: Displaying the Hidden Service
View the generated .onion address:
sudo cat /var/lib/tor/hidden_service/hostname
The displayed .onion address is your Hidden Service address. You can use it to access your hosted website or service.
Remember that securing Hidden Services is a complex matter. Make sure to familiarize yourself with Tor security best practices and regularly monitor your server to ensure its security.