This is a quick tutorial on how to set up a Tor website using Nginx on Ubuntu.
Step 1: Install Nginx
Type: sudo apt install nginx
Type: sudo nano /etc/nginx/sites-available/default
Replace the entire contents of the file with the code block below.
server { listen 127.0.0.1:8080 default_server; server_name localhost; root /usr/share/nginx/html; index index.html index.htm; location / { allow 127.0.0.1; deny all; } }
Step 2: Install Tor
Type: lsb_release -a
Note down your Linux release version and codename.
Then visit this link and select your Linux version and codename from the drop down menu.
Follow the instructions on that page, then continue back here.
Type: sudo nano /etc/tor/torrc
Look for the following two lines of code and uncomment them, then change “127.0.0.1:80” to “127.0.0.1:8080”.
#HiddenServiceDir /var/lib/tor/hidden_service/ #HiddenServicePort 80 127.0.0.1:80
After making those changes, the two lines should now look like this:
HiddenServiceDir /var/lib/tor/hidden_service/ HiddenServicePort 80 127.0.0.1:8080
Step 3: Restart the Services
Type: sudo service nginx restart
Type: sudo service tor restart
Step 4: Test Your Tor Website
Type: sudo nano /var/lib/tor/hidden_service/hostname
Copy your .onion hostname and try it out in your Tor Browser.
Your websites html files can be found in /usr/share/nginx/html
As a final note, I strongly advise you to read Tor Hidden (Onion) Services Best Practices.