Questions about leak prevention

I am following the guide at

I am new to this and I wanted to host a simple html site for learning purposes, I got to the following part:

Tip: A good practice to avoid leaking an Onion Service to a local network is to run Onion Services over Unix sockets instead of a TCP socket. You will need to add the following two lines to your torrc file:

HiddenServiceDir /var/lib/tor/my-website/
HiddenServicePort 80 unix:/var/run/tor/my-website.sock

I am a little confused, further up in the guide the example website name was my_website

So, my question is, when it says my-website is the - a typo and is supposed to be an underscore or is that a different name on purpose? If the name I use is onion, should the part about leaking prevention also be onion or should it be something else?

Thanks in advance for the help.

The my-website or my_website in the guide is largely an example string which you can replace with anything as long as it works.

The HiddenServiceDir is not the place you put your website content (like index.html) in. The HiddenServiceDir is where Tor daemon stores the necessary files of this specific Onion service (like Onion service private, public keypair, onion client authorization pubkeys). To serve a webpage over onion service, you need to have a web server running, configure it to serve the webpage, and direct the HiddenServicePort to the port it’s listening on.
For example, if you used python -m http.server to start a simple http server on port 8000, you need to have HiddenServicePort 80 127.0.0.1 8000 configured in torrc so you can access the web server by visiting the onion service from a Tor browser. (Don’t use python’s built in web server if you’re running an onion service seriously, it listens on every network interface so is visible from network unless you have a firewall installed.)

HiddenServiceDir can be anywhere, but usually it’s best to keep it under the folder your Tor daemon stores its data, i.e. /var/lib/tor if you install tor daemon from your distribution’s package manager.

Pointing HiddenServicePort to a UNIX socket is a bit more advanced. Some web servers (like NGINX) can listen on a UNIX socket (a “file”, so to speak) instead of on a port. Instead of anyone that can reach you through network, now only the programs on your computer can reach this website (your Onion service). If you configure NGINX to listen on /run/nginx-website.sock, you should have HiddenServicePort 80 unix:/run/nginx-website.sock in your torrc.

Maybe I didn’t explain myself well.

I am aware that 'HiddenServiceDir" can be anything, but please look at these

You will need to add the following two lines to your torrc file:

 HiddenServiceDir /var/lib/tor/my_website/
 HiddenServicePort 80 127.0.0.1:80

AND

Tip: A good practice to avoid leaking an Onion Service to a local network is to run Onion Services over Unix sockets instead of a TCP socket. You will need to add the following two lines to your torrc file:

HiddenServiceDir /var/lib/tor/my-website/
HiddenServicePort 80 unix:/var/run/tor/my-website.sock

You can see that the first has my_website

While the second has my-website

While I am fully aware that these fields should be edited with what I call the website the first one is my UNDERSCORE website

The second is my DASH website

Now. I am autistic, so this may just be me being overly precise, but this confuses me greatly.

Are these two different websites? Are these the same website and they just accidentally written the example folder/name in a different way? Are they all supposed to be the same website or are we talking about different websites coexisting on the same device?

It just shows two ways to setup your hidden service, with either a port/TCP socket or a file/Unix socket. If it helps your autistic thinking, think of it as the same site, just two different ways to do it.

This makes me think you believe the socket snippet from the documentation page you linked to be meant to be used in addition to the port one. You pick either one, not both at the same time.

The key word in the paragraph from the documentation is instead:

A good practice to avoid leaking an Onion Service to a local network is to run Onion Services over Unix sockets instead of a TCP socket

The example should theoretically use the same name consistently, either underscore or dash.

OH!

Thank you so much! I don’t know how I was lost in that part, I feel so silly right now but I am happy I finally get it!

You were very kind, I appreciate the time you took to help me out <3