Serve Onion Hidden Service behind Caddy reverse proxy

I’m using latest Caddy inside Docker GitHub - abiosoft/caddy-docker: Docker container for Caddy in a compose.

Here what I want to do:

I run 2 server on different ports, I want to expose them via Caddy reverse proxy with an Onion Hidden Service. This what I tried

localhost:8080 {
  proxy /fisrt localhost:3000
  proxy /second localhost:4000

All it works inside the machine

Now if I configure my hidden service with the following torrc

DataDirectory /var/lib/tor
HiddenServiceDir /var/lib/tor/hidden_service
HiddenServiceVersion 3
HiddenServicePort 80

If i go via Tor Browser it says 404 Site XXX.onion is not served on this interface

Even if I try to add the onion URI inside the Caddyfile I have no luck.

Any clue?

Hi @tiero, welcome to the Caddy community.

Just to check, you’ve tried taking XXX.onion from the error message and using it as the site label in your Caddyfile?

Just a hunch, but localhost and, while they resolve to the same IP, aren’t actually the same. You could try using as your site label instead (or even just :8080 without an IP/domain to handle anything on that port)


This is a good step, at least for testing, because it won’t matter what host / domain name people request - they’ll get your site.

It worked!

I was already using in the caddyfile as site label the .onion address, but moving from localhost:8080 to :8080 solved! Thanks


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.