Caddy proxy to VM on truenas

1. The problem I’m having:

Hi, I’m trying to use Caddy as a reverse proxy for a Home Assistant VM hosted on Truenas.
Caddy is already acting as a reverse proxy to other applications (but not VMs) on the same Truenas machine.
The Home Assistant VM is accessible locally at http://192.168.1.35:8123.
When I attempt to connect via caddy on https://home.test.com I get an error 502 (Bad Gateway)

2. Error messages and/or full log output:

2025-08-15 16:17:12.466667+00:00{"level":"error","ts":1755274632.466511,"logger":"http.log.error","msg":"dial tcp 192.168.1.35:8123: connect: no route to host","request":{"remote_ip":"192.168.1.254","remote_port":"48290","client_ip":"192.168.1.254","proto":"HTTP/2.0","method":"GET","host":"home.test.com","uri":"/","headers":{"Sec-Fetch-Dest":["document"],"Sec-Fetch-Site":["none"],"Priority":["u=0, i"],"Sec-Fetch-User":["?1"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64; rv:141.0) Gecko/20100101 Firefox/141.0"],"Sec-Fetch-Mode":["navigate"],"Accept-Language":["en-US,en;q=0.5"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Sec-Gpc":["1"],"Upgrade-Insecure-Requests":["1"],"Te":["trailers"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"]},"tls":{"resumed":true,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"home.test.com"}},"duration":1.254436976,"status":502,"err_id":"rbrdc0ca8","err_trace":"reverseproxy.statusError (reverseproxy.go:1390)"}

3. Caddy version:

v2.10.0 h1:fonubSaQKF1YANl8TXqGcn4IbIRUDdfAkpcsfI/vX5U=

4. How I installed and ran Caddy:

Caddy is installed as a Truenas application (docker)

a. System environment:

Latest Truenas Scale (25.04.2.1)

c. Compose

services:
  caddy:
    image: caddy:latest
    restart: unless-stopped
    environment:
      - PUID=568
      - PGID=568
      - TZ=Europe/Paris
    cap_add:
      - NET_ADMIN
    ports:
      - "80:80"
      - "443:443"
      - "443:443/udp"
    volumes:
      - /mnt/SSD-Mirror/services/caddy/data:/data
      - /mnt/SSD-Mirror/services/caddy/Caddyfile:/etc/caddy/Caddyfile
      - /home/truenas_admin/websites/:/websites

d. My complete Caddy config:

home.test.com {
        reverse_proxy 192.168.1.35:8123
}

(obviously there are other lines for the other services but this is the only part that’s relevant)

Thank you for any help. :person_bowing:

It seems your Caddy container doesn’t know where 192.168.1.35 is, can’t route to it.

1 Like

I was doing the bridge setup on Truenas incorrectly, see here for more info on how I fixed it:

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