serviceporttor

Running multiple services on different ports on the same onion domain?


Context

In some form the opposite of this question; how can one host multiple services on a single onion domain?

When I include:

HiddenServiceDir /var/lib/tor/gitlab/
HiddenServicePort 8070 127.0.0.1:8050
HiddenServiceDir /var/lib/tor/dash/
HiddenServicePort 9002 127.0.0.1:9001

and create the files

HiddenServiceDir /var/lib/tor/gitlabhostname
HiddenServiceDir /var/lib/tor/dash/hostname

Both hostnames will get an onion domain. Hence, I was wondering:

Question

How can I ensure only 1 onion domain is created for both services? (dash and gitlab in this example).

Note

I expect that I misunderstand the purpose of the /var/lib/tor/<service_name>/ folder, and that perhaps the /var/lib/tor/<service_name>/hostname` file is not required for (each) onion service. (In essence that it is only used to store e.g. some website data if needed). However, I did not yet figure out how this works.


Solution

  • Yes, you can specify mutliple HiddenServicePort for one HiddenServiceDir, according to https://tor.stackexchange.com/a/4439

    HiddenServiceDir /path/to/hs/dir/
    HiddenServicePort 80 127.0.0.1:80
    HiddenServicePort 8000 127.0.0.1:8000
    HiddenServicePort 81 192.168.0.102:80