Introduction:
A Tor .onion site, often referred to as the “dark web,” provides anonymity and privacy to both website operators and users. Hosting one on a CentOS 8 server using Nginx and Tor can be a complex but rewarding endeavor. In this guide, we’ll walk you through the steps to set up a Tor .onion site on your CentOS 8 server, allowing you to offer your content securely and anonymously.
Prerequisites:
Before you begin, make sure you have the following:
- A CentOS 8 server with root or sudo access.
- Nginx installed and configured to serve your website.
- Basic knowledge of Linux commands and server administration.
Step 1: Install and Configure Nginx:
If you haven’t already set up Nginx, you can install it using the following commands:
sudo yum install epel-release
sudo yum install nginx
Once installed, configure Nginx to serve your website content by creating an Nginx server block. You can use the default configuration or create a custom one based on your needs.
Step 2: Install and Configure Tor:
Install Tor on your CentOS 8 server with the following commands:
sudo yum install tor
After the installation, open the Tor configuration file:
sudo nano /etc/tor/torrc
Add or modify the following lines in the configuration file:
HiddenServiceDir /var/lib/tor/your_onion_site/
HiddenServicePort 80 127.0.0.1:80
Replace /var/lib/tor/your_onion_site/
with your preferred directory for Tor’s data files.
Step 3: Configure Nginx for Tor:
Next, configure Nginx to work with Tor. Create a new server block configuration file:
sudo nano /etc/nginx/conf.d/your_site_tor.conf
Inside this file, add the following configuration:
server {
listen 127.0.0.1:80;
server_name your_onion_domain.onion;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
Make sure to replace your_onion_domain.onion
with your desired .onion domain.
Step 4: Start Tor and Nginx:
Start the Tor service and enable it to start on boot:
sudo systemctl start tor
sudo systemctl enable tor
Then, restart Nginx to apply the changes:
sudo systemctl restart nginx
Step 5: Access Your Tor .onion Site:
Once everything is set up, you can access your Tor .onion site by checking the hostname generated by Tor. Run the following command to get your .onion domain:
sudo cat /var/lib/tor/your_onion_site/hostname
This command will display your .onion domain, something like “your_onion_domain.onion.”
Step 6: Secure Your .onion Site:
To enhance security, consider implementing HTTPS using a free certificate provider like Let’s Encrypt.
Conclusion:
You’ve successfully set up a Tor .onion site on your CentOS 8 server using Nginx and Tor. This allows you to offer your content with enhanced privacy and anonymity. Remember to keep your site secure and up-to-date to maintain the integrity of your .onion presence on the Tor network.