Tor is an anonymity service and software that routes traffic by way of three volunteer-run servers called relays. The three-hop design is to ensure privacy by resisting surveillance attempts.
One feature of Tor is that you can run hidden, Tor-exclusive websites called onion services. All traffic to an onion service is therefore private and encrypted.
With the packages installed, you need to configure Tor. The author uses vi for this, but if you prefer nano or something else, go ahead and substitute that in:
vi/etc/tor/torrc
The default torrc file is pretty descriptive, but can get long if you just want an onion service. A minimum onion service configuration is similar to this:
The "HiddenServiceDir" is the location of your onion service's hostname and cryptographic keys. You are storing these keys at /var/lib/tor/onion-site/
The "HiddenServicePort" is the port forwarding from your local server to the onion service. You are forwarding 127.0.0.1:80 to port 80 on our Tor-facing service
Warning
If you plan to use a directory for your onion service signing keys outside of /var/lib/tor/, you will need to make sure the permissions are 0700 and the owner is toranon:toranon.
You will also need a web server on our machine to service clients to your onion service. Any web server (Caddy, Apache, or Nginx) is usable. The author prefers Caddy. For simplicity's sake, install Caddy:
dnf-yinstallcaddy
Next, you will insert the following to /etc/caddy/Caddyfile:
Onion services are an invaluable tool if you are hosting a website privately or need to bypass your ISP's Carrier Grade NAT using only open source software.
While onion services are not as fast as hosting a website directly (understandable due to Tor's privacy-first design), it is way more secure and private than the public internet.