Home · Guides / 5
Guide 5 of 5
How to secure a .onion server
The original security notes are short: send host DNS through Tor, then follow standard NGINX hardening and optional port knocking for SSH.
Send host DNS through Tor
-
Add these directives to
/etc/tor/torrc(then restart Tor):VirtualAddrNetworkIPv4 10.192.0.0/10 AutomapHostsOnResolve 1 TransPort 9040 TransListenAddress 127.0.0.1 DNSPort 53Newer Tor buildsTransListenAddressis legacy syntax. Current Tor prefers address/port onTransPort/DNSPort. Checkman toron your release before copying this block blindly. -
Point the resolver at Tor’s DNS port.
sudo vi /etc/resolv.confnameserver 127.0.0.1sudo service network restartOn systemd-resolved hosts you may need a matching change in
/etc/systemd/resolved.confor the change will be overwritten.
Onion-specific hardening
The next page is the one to finish with: Tor’s own packages, unix sockets, key backup, DoS defenses, optional client auth, and headers for a static site.
Secure NGINX
These topics were originally listed as external articles. The walkthroughs now live here, with credit on each page:
Optional: knockd for remote access
If you still expose SSH on a cloud host, port knocking can keep the port closed until a known sequence is sent.