I have a few hidden services on my Ubuntu Server using Nginx. My torrc looks something like this:

HiddenServiceDir /var/lib/tor/hs1
HiddenServicePort 80

HiddenServiceDir /var/lib/tor/hs2
HiddenServicePort 80

I can access the homepage of both using their onion addresses, but clicking any subdirectories e.g. *.onion/blog/ sends me to *.onion:8081/blog/

I know all the basics are set up correctly, I can access both sites from localhost and through Tor, but anything besides the index page is sent to the local port, not the virtual port.

My Nginx configuration for HS1 is:

server {
        server_name testoniondomain1.onion;
        root /var/www/sites/hs1;
        index index.html index.htm index.php;

Am I missing something obvious or is there a problem with my configuration? Thank you in advance

1 Answer 1


Are you sure it's clicking on subdirectories causing the problem? nginx should just provide any existing file/directory that exists, and should not be aware what port it is serving the content on.

If, on the other hand, the problem is that going to *.onion/subdir (no slash at the end) redirects to *.onion:8081/subdir/, then you might be looking for the port_in_redirect off directive in the server block, as described in:


If you are using further proxied servers, there may be other tweaks needed.

  • +1 port_in_redirect was exactly what I was missing, thank you!
    – jpl42
    Dec 16, 2015 at 2:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .