Tor
sudo apt install tor usually does it.
Make sure to open port 9050:
sudo ufw allow 9050
If using NGINX, make sure these settings are set:
port_in_redirect off;
server_name_in_redirect off;
server_names_hash_bucket_size 125;
server_tokens off;
Edit the Tor configuration at /etc/tor/torrc and add hidden services:
HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServicePort 80 127.0.0.1:8080
Restart Tor with sudo systemctl restart tor and find the onion address with:
sudo cat /var/lib/tor/hidden_service/hostname
Here is an example NGINX configuration making a Teddit instance available as an onion:
server {
server_name teddit.zcyph.cc tpgzjkhxywpv4qjajqsitx4ywmtdrphjt3crbncfhelsyhfd6sr3w7yd.onion;
location / {
proxy_pass http://127.0.0.1:8080;
}
add_header Onion-Location http://tpgzjkhxywpv4qjajqsitx4ywmtdrphjt3crbncfhelsyhfd6sr3w7yd.onion$request_uri;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/teddit.zcyph.cc-0003/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/teddit.zcyph.cc-0003/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = teddit.zcyph.cc) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name teddit.zcyph.cc tpgzjkhxywpv4qjajqsitx4ywmtdrphjt3crbncfhelsyhfd6sr3w7yd.onion;
return 404; # managed by Certbot
}