How to setup Caddy for v23?

I had caddy partially working in a previous version (maybe v22?) but never got it fully working (I always had to specify the port on the end of the domain). Now it seems things have changed and the caddy setup is different but I still cannot get it working based on the current sample in the doc.

This is my docker compose file

version: '3'

services:

    vikunja:
        image: vikunja/vikunja
        container_name: vikunja
        environment:
            VIKUNJA_SERVICE_JWTSECRET: $VIKUNJA_SERVICE_JWTSECRET
            VIKUNJA_SERVICE_PUBLICURL: http://192.168.1.101:3456
            VIKUNJA_SERVICE_ENABLEREGISTRATION: false
            VIKUNJA_SERVICE_TIMEZONE: America/Vancouver
            VIKUNJA_DATABASE_PATH: /db/vikunja.db
        ports:
            - 3456:3456
        volumes:
            - /home/mcp/apps/vikunja/files:/app/vikunja/files
            - /home/mcp/apps/vikunja/db:/db
        restart: unless-stopped

I have this at the bottom of my Caddyfile as per the doc

vikunja.mydomain.ca {
	reverse_proxy api:3456
}

Which throws this error in the Caddy log when I try to visit the url in my browser.

ERR ts=1711738654.5501566 logger=http.log.error msg=dial tcp: lookup api on 127.0.0.11:53: no such host request={"remote_ip":"192.168.1.147","remote_port":"49776","client_ip":"192.168.1.147","proto":"HTTP/3.0","method":"GET","host":"vikunja.mydomain.ca","uri":"/","headers":{"Sec-Fetch-Dest":["document"],"Accept-Encoding":["gzip, deflate, br"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"],"Sec-Fetch-Site":["none"],"Priority":["u=0, i"],"Sec-Fetch-Mode":["navigate"],"Accept-Language":["en-CA,en-US;q=0.9,en;q=0.8"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h3","server_name":"vikunja.mydomain.ca"}} duration=0.010880028 status=502 err_id=cav4f3na5 err_trace=reverseproxy.statusError (reverseproxy.go:1267)

This works with all my other services…

*.mydomain.ca {
	tls {
		dns cloudflare XcZk************imko71
	}
	@homepage host dashboard.mydomain.ca
	handle @homepage {
		reverse_proxy 192.168.1.101:3000
	}

	...
	
    @vikunja host vikunja.mydomain.ca
	handle @vikunja {
		reverse_proxy 192.168.1.101:3456
	}

}

I’ve also tried some other variants but they all return the same or similar error.

	@vikunja host vikunja.mydomain.ca
	handle @vikunja {
		reverse_proxy https://192.168.1.101:3456
	}
	@vikunja host vikunja.mydomain.ca
	handle @vikunja {
		reverse_proxy http://192.168.1.101:3456
	}

I’m very new to reverse proxies and am not sure how to debug this.

Never mind. I got it working. I swear I had tried this line during my troubleshooting but either I hadn’t or there was some other config issue interfering.

Caddyfile

...
	@vikunja host vikunja.mydomain.ca
	handle @vikunja {
		reverse_proxy 192.168.1.101:3456
	}
...

Docker compose file

...
        VIKUNJA_SERVICE_PUBLICURL: https://vikunja.mydomain.ca
...
1 Like