TOR Hidden Service - jonatello/lab-musing GitHub Wiki
This configuration assumes Nginx and the website itself is already configured and functioning.
Configuration:
Install the TOR package
pkg install tor
Configure torrc by uncommenting "SOCKSPort 9050", uncommenting the "Log notice" lines
sed -i '' 's/#SOCKSPort 9050/SOCKSPort 9050/g' /usr/local/etc/tor/torrc
sed -i '' 's/#Log notice file \/var\/log\/tor\/notices.log/Log notice file \/var\/log\/tor\/notices.log/g' /usr/local/etc/tor/torrc
sed -i '' 's/#Log notice syslog/Log notice syslog/g' /usr/local/etc/tor/torrc
Now add the following to the torrc config to set the Hidden Service directory and listening ports of 80 and 443
echo 'HiddenServiceDir /var/db/tor/hidden_service/' >> /usr/local/etc/tor/torrc
echo 'HiddenServicePort 80 127.0.0.1:80' >> /usr/local/etc/tor/torrc
echo 'HiddenServicePort 443 127.0.0.1:443' >> /usr/local/etc/tor/torrc
Or just use "tor.torrc"
Enable TOR via rc.conf
sysrc tor_enable=yes
Start TOR
service tor start
Note down the hidden service URL from the hostname file (It will be a %LongString%.onion)
cat /var/db/tor/hidden_service/hostname
Add this hidden service URL to the existing Nginx server_name list
Troubleshooting
Test the server via curl
curl -v 127.0.0.1:9050