Skip to main content

Create a hidden Service

Install Tor

First, you need to install the Tor service. This can be done via the package manager.

apt update
apt install tor

Configure Tor

Next, you need to configure Tor to host your hidden service. Open the Tor configuration file:

vim /etc/tor/torrc

Add the following lines at the end of the file:

HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServicePort 80 127.0.0.1:80

Restart Tor

After making the changes, restart the Tor service to apply the configuration.

systemctl restart tor

Find Your Onion Address

The Tor service generates the onion address for your hidden service. To find it, check the hostname file.

cat /var/lib/tor/hidden_service/hostname

This command will output an onion address that you can use to access your site via the Tor network.

Install and Configure Nginx

If you haven't installed Nginx yet, you can do so with the following command:

apt install nginx

After installation, you need to configure Nginx to serve your website. Create a new configuration file for your onion service:

vim /etc/nginx/sites-available/onion

Add the following configuration:

server {
    listen 80;
    server_name your_onion_address.onion;

    location / {
        root /var/www/html;  # Change this to your website directory
        index index.html index.htm;
    }
}

Enable the Nginx Configuration

ln -s /etc/nginx/sites-available/onion /etc/nginx/sites-enabled/

Edit the Nginx Configuration

Open your main Nginx configuration file:

vim /etc/nginx/nginx.conf

Increase the Bucket Size

Add or modify the server_names_hash_bucket_size directive within the http block. You could set it to a larger value, like 128 or 256:

http ##{
    ...
    server_names_hash_bucket_size 128;
    ...
}

Test Nginx Configuration

Check for any syntax errors in the Nginx configuration:

nginx -t

nginx -t

## 

Restart Nginx

If the configuration test is successful, restart Nginx:

systemctl restart nginx

##

Place Your Website Files

Place your HTML files in the designated directory (e.g., `/var/www/html`html). You can create a simple `index.html`html file to test:

echo "

<h1>Welcome to My Onion Site!

</h1>" | sudo tee /var/www/html/index.html