Caddy in docker blocked accessing other docker containers

1. The problem I’m having:

Difficulty with Caddy as reverse proxy to various docker containers.

I am not trying to use HTTPS yet, just want to get reverse_proxy working as simply as possible first.

I am attempting to access things via a static IP (which all works if I open ports etc) eg http://144.6.86.11/homepage (http://144.6.86.11:3000 works)

These containers and caddy are in docker containers on Ubuntu which is installed as a VM on Proxmox with the port forwarded to Caddy - I can access caddy etc - I have a test script which runs on http://144.6.86.11/)

I have latest Caddy installed - with all containers on a network called reverse_proxy_network

The ports are the mapped ports of each container . EG Flatnotes is listening on 8080 but mapped to 8085. So I target flatnotes:8085

Generally no containers are working except Jellyfin.

Some containers will load, but are unable to deliver content as the files they are loading such as javascript or css are blocked. For example console errors show they are requesting files at http://144.6.86.11/_next/static which fails. However it would succeed if i opened the port directly.

So to be clear this will fail http://144.6.86.11/homepage - but the html page shows with no javascript or css files (broken links)

         handle_path /homepage* {
                reverse_proxy homepage:3000
        }

However it will work with the port - directly open. http://144.6.86.11:3000

What is strange is that if I use handle_path /homarr* it fails.

EG this fails:

handle_path /homarr* {
    reverse_proxy homarr:7575
}

However this will work.

handle {
   reverse_proxy homarr:7575
     }

2. Error messages and/or full log output:


caddy-1  | {"level":"info","ts":1732595532.007136,"msg":"using config from file","file":"/etc/caddy/Caddyfile"}
caddy-1  | {"level":"info","ts":1732595532.008871,"msg":"adapted config to JSON","adapter":"caddyfile"}
caddy-1  | {"level":"warn","ts":1732595532.0088842,"msg":"Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies","adapter":"caddyfile","file":"/etc/caddy/Caddyfile","line":3}
caddy-1  | {"level":"info","ts":1732595532.0099447,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//127.0.0.1:2019","//localhost:2019","//[::1]:2019"]}
caddy-1  | {"level":"info","ts":1732595532.010211,"logger":"http.auto_https","msg":"automatic HTTPS is completely disabled for server","server_name":"srv0"}
caddy-1  | {"level":"info","ts":1732595532.0104537,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc00067ed00"}
caddy-1  | {"level":"info","ts":1732595532.01208,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
caddy-1  | {"level":"info","ts":1732595532.012382,"msg":"autosaved config (load with --resume flag)","file":"/config/caddy/autosave.json"}
caddy-1  | {"level":"info","ts":1732595532.012394,"msg":"serving initial configuration"}
caddy-1  | {"level":"info","ts":1732595532.0161154,"logger":"tls","msg":"storage cleaning happened too recently; skipping for now","storage":"FileStorage:/data/caddy","instance":"ba34b56d-ebbc-44e9-985e-1dfd3bef4ddc","try_again":1732681932.0161135,"try_again_in":86399.999999398}
caddy-1  | {"level":"info","ts":1732595532.0163336,"logger":"tls","msg":"finished cleaning storage units"}
caddy-1  | {"level":"info","ts":1732596122.0441136,"logger":"admin.api","msg":"received request","method":"POST","host":"localhost:2019","uri":"/load","remote_ip":"127.0.0.1","remote_port":"44198","headers":{"Accept-Encoding":["gzip"],"Content-Length":["2799"],"Content-Type":["application/json"],"Origin":["http://localhost:2019"],"User-Agent":["Go-http-client/1.1"]}}
caddy-1  | {"level":"info","ts":1732596122.045563,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//127.0.0.1:2019","//localhost:2019","//[::1]:2019"]}
caddy-1  | {"level":"info","ts":1732596122.0458503,"logger":"http.auto_https","msg":"automatic HTTPS is completely disabled for server","server_name":"srv0"}
caddy-1  | {"level":"info","ts":1732596122.0470948,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
caddy-1  | {"level":"info","ts":1732596122.0471148,"logger":"http","msg":"servers shutting down with eternal grace period"}
caddy-1  | {"level":"info","ts":1732596122.0474205,"msg":"autosaved config (load with --resume flag)","file":"/config/caddy/autosave.json"}
caddy-1  | {"level":"info","ts":1732596122.0476036,"logger":"admin.api","msg":"load complete"}
caddy-1  | {"level":"info","ts":1732596122.0495849,"logger":"admin","msg":"stopped previous server","address":"localhost:2019"}
caddy-1  | {"level":"error","ts":1732596128.75599,"logger":"http.log.error","msg":"dial tcp 172.25.0.6:3008: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52446","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/","headers":{"Cache-Control":["max-age=0"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"],"If-Modified-Since":["Tue, 26 Nov 2024 01:19:14 GMT"],"If-None-Match":["\"d5vpr4u9hw821gj\""]}},"duration":0.000756295,"status":502,"err_id":"d9m1rvb56","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"info","ts":1732596163.2763247,"logger":"admin.api","msg":"received request","method":"POST","host":"localhost:2019","uri":"/load","remote_ip":"127.0.0.1","remote_port":"38234","headers":{"Accept-Encoding":["gzip"],"Content-Length":["2798"],"Content-Type":["application/json"],"Origin":["http://localhost:2019"],"User-Agent":["Go-http-client/1.1"]}}
caddy-1  | {"level":"info","ts":1732596163.277564,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]}
caddy-1  | {"level":"info","ts":1732596163.277775,"logger":"http.auto_https","msg":"automatic HTTPS is completely disabled for server","server_name":"srv0"}
caddy-1  | {"level":"info","ts":1732596163.278871,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
caddy-1  | {"level":"info","ts":1732596163.278895,"logger":"http","msg":"servers shutting down with eternal grace period"}
caddy-1  | {"level":"info","ts":1732596163.2790902,"msg":"autosaved config (load with --resume flag)","file":"/config/caddy/autosave.json"}
caddy-1  | {"level":"info","ts":1732596163.2790976,"logger":"admin.api","msg":"load complete"}
caddy-1  | {"level":"info","ts":1732596163.2811942,"logger":"admin","msg":"stopped previous server","address":"localhost:2019"}
caddy-1  | {"level":"error","ts":1732596171.7988179,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52488","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/","headers":{"Upgrade-Insecure-Requests":["1"],"Cookie":["REDACTED"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Connection":["keep-alive"],"Cache-Control":["max-age=0"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"]}},"duration":0.000862197,"status":502,"err_id":"8h7ti8z02","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596175.7395568,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52488","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/api/config/custom.css","headers":{"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["text/css,*/*;q=0.1"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"]}},"duration":0.00096169,"status":502,"err_id":"3cag79mwe","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596175.7695816,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52494","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/css/c223d5e83fb92340.css","headers":{"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["text/css,*/*;q=0.1"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"]}},"duration":0.001032837,"status":502,"err_id":"6hqymqgpd","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596175.7695913,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52495","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/fa72304b.5562f734f33fbe10.js","headers":{"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"]}},"duration":0.001042844,"status":502,"err_id":"x08d3mgi2","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596175.7705564,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52497","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/webpack-ff6990588c3b928e.js","headers":{"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"]}},"duration":0.000408906,"status":502,"err_id":"wkv1yq2h1","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596175.7707038,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52496","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/7151.bae9be65e631d24f.js","headers":{"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"]}},"duration":0.000953947,"status":502,"err_id":"1j1r7estn","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596175.7715352,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52498","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/framework-fb129ad84e3a607e.js","headers":{"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"]}},"duration":0.00067596,"status":502,"err_id":"dswmi6w3i","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596175.7725904,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52488","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/main-0ddda9b10a00d3ad.js","headers":{"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"]}},"duration":0.000414866,"status":502,"err_id":"8exnms37p","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596175.791436,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52494","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/pages/_app-2da6463c8d7db6b5.js","headers":{"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"]}},"duration":0.000927994,"status":502,"err_id":"j5s8xghhh","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596175.791556,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52495","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/bdd0c3b4-d5f5b5aed8cd8328.js","headers":{"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"]}},"duration":0.001175777,"status":502,"err_id":"fyek5a15q","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596175.7916677,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52496","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/2f278442-021d79724fdbde09.js","headers":{"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"]}},"duration":0.00104609,"status":502,"err_id":"ryrz1sxea","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596175.7917974,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52498","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/3eea48ae-ac1da50fec44110d.js","headers":{"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"]}},"duration":0.00103158,"status":502,"err_id":"z0p0drcrb","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596175.7919595,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52497","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/31659383-e4abe7629b906c35.js","headers":{"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"]}},"duration":0.001580817,"status":502,"err_id":"tn1srvy8r","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596175.7919636,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52488","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/9201-12240fd0587e22ee.js","headers":{"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"]}},"duration":0.001104137,"status":502,"err_id":"qu8xutz54","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596175.8145144,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52488","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/pages/index-436cb4e75ae4486d.js","headers":{"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"]}},"duration":0.00072976,"status":502,"err_id":"hb22ri5jc","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596175.8145463,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52497","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/CwPbuoexdZ8g6a4w7pYdo/_buildManifest.js","headers":{"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"]}},"duration":0.000851612,"status":502,"err_id":"phqkipqsp","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596175.8145292,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52498","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/CwPbuoexdZ8g6a4w7pYdo/_ssgManifest.js","headers":{"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"]}},"duration":0.000833918,"status":502,"err_id":"6km3ptpze","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596436.4285438,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52498","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/api/config/custom.css","headers":{"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["text/css,*/*;q=0.1"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"]}},"duration":0.001027354,"status":502,"err_id":"wqt67ca0r","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596436.4311893,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52497","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/css/c223d5e83fb92340.css","headers":{"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["text/css,*/*;q=0.1"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"]}},"duration":0.0006532,"status":502,"err_id":"d6da1sja1","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596436.4447,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52497","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/fa72304b.5562f734f33fbe10.js","headers":{"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"]}},"duration":0.000907502,"status":502,"err_id":"zidazqdgp","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596436.444846,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52498","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/7151.bae9be65e631d24f.js","headers":{"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"]}},"duration":0.000384458,"status":502,"err_id":"d24dhyec5","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596436.4452572,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52488","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/webpack-ff6990588c3b928e.js","headers":{"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"]}},"duration":0.00107256,"status":502,"err_id":"uxase7wf8","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596436.4478605,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52496","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/framework-fb129ad84e3a607e.js","headers":{"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"]}},"duration":0.000564259,"status":502,"err_id":"6qje49uf1","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596436.4502115,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52495","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/main-0ddda9b10a00d3ad.js","headers":{"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"]}},"duration":0.000577698,"status":502,"err_id":"emi1p7qhd","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596436.4520407,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52494","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/pages/_app-2da6463c8d7db6b5.js","headers":{"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"]}},"duration":0.000569852,"status":502,"err_id":"giypwiwgf","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596436.4621978,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52497","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/bdd0c3b4-d5f5b5aed8cd8328.js","headers":{"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"]}},"duration":0.000980172,"status":502,"err_id":"94fqie32y","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596436.4649167,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52495","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/31659383-e4abe7629b906c35.js","headers":{"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"]}},"duration":0.000653117,"status":502,"err_id":"z1us2ddu5","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596436.4661548,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52494","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/2f278442-021d79724fdbde09.js","headers":{"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"]}},"duration":0.000573132,"status":502,"err_id":"t3ixz2ixb","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596436.4673207,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52498","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/3eea48ae-ac1da50fec44110d.js","headers":{"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"]}},"duration":0.000541968,"status":502,"err_id":"5bkyx29jj","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596436.4791455,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52488","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/9201-12240fd0587e22ee.js","headers":{"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"]}},"duration":0.000665709,"status":502,"err_id":"49jjnneha","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596436.4791503,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52496","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/chunks/pages/index-436cb4e75ae4486d.js","headers":{"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"]}},"duration":0.000672496,"status":502,"err_id":"apr6urpty","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596436.4931946,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52496","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/CwPbuoexdZ8g6a4w7pYdo/_buildManifest.js","headers":{"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"]}},"duration":0.000771289,"status":502,"err_id":"33t3j8508","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596436.4947321,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52488","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/_next/static/CwPbuoexdZ8g6a4w7pYdo/_ssgManifest.js","headers":{"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"]}},"duration":0.000578938,"status":502,"err_id":"yu6d4n6gr","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"error","ts":1732596451.8979974,"logger":"http.log.error","msg":"dial tcp 172.25.0.9:8085: connect: connection refused","request":{"remote_ip":"192.168.20.1","remote_port":"52488","client_ip":"192.168.20.1","proto":"HTTP/1.1","method":"GET","host":"144.6.86.11","uri":"/site.webmanifest?v=4","headers":{"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://144.6.86.11/homepage"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,en-AU;q=0.8"],"Cookie":["REDACTED"],"Connection":["keep-alive"]}},"duration":0.001473213,"status":502,"err_id":"u6up4eacd","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
caddy-1  | {"level":"info","ts":1732596594.2327225,"logger":"admin.api","msg":"received request","method":"POST","host":"localhost:2019","uri":"/load","remote_ip":"127.0.0.1","remote_port":"39150","headers":{"Accept-Encoding":["gzip"],"Content-Length":["2798"],"Content-Type":["application/json"],"Origin":["http://localhost:2019"],"User-Agent":["Go-http-client/1.1"]}}
caddy-1  | {"level":"info","ts":1732596594.2330928,"msg":"config is unchanged"}
caddy-1  | {"level":"info","ts":1732596594.2331054,"logger":"admin.api","msg":"load complete"}

3. Caddy version:

v2.8.4

4. How I installed and ran Caddy:

I am using docker-compose.yml with Caddyfile

a. System environment:

Ubuntu latest running in a container on Proxmox.

b. Command:

docker compose up -d

c. Service/unit/compose file:

services:
  caddy:
    networks:
      - reverse_proxy_network
    image: caddy:latest
    restart: unless-stopped
    ports:
#      - "80:80"
      - "8080:80"
#      - "443:443"
#     - "443:443/udp"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - ./site:/srv
      - caddy_data:/data
      - caddy_config:/config

volumes:
  caddy_data:
  caddy_config:
networks:
  reverse_proxy_network:
    name: reverse_proxy_network
    external: true

d. My complete Caddy config:


{
        auto_https disable_redirects
    auto_https off
}

http://144.6.86.11 {
        handle_path /flatnotes* {
              reverse_proxy flatnotes:8085
        }
        handle_path /jellyfin* {
               reverse_proxy jellyfin:8096
}

        handle_path /news-rss* {
               reverse_proxy freshrss:8081
}


         handle_path /homepage* {
                reverse_proxy homepage:3000
        }
        handle_path /homarr* {
                reverse_proxy homarr:7575
}
        handle_path /games* {
                reverse_proxy emulatorjs:3008
        }

       handle {
		reverse_proxy flatnotes:8085
#             root * /srv
#            file_server
        }

}

5. Links to relevant resources:

This behaviour isn’t a bug or a problem with Caddy or the upstream server, but rather, a logical issue relating to how webroots work. In short, this issue is caused by trying to reverse-proxy an app into a subfolder when the app isn’t prepared for that.

I’ve written a relatively comprehensive overview of the issue and what your options are:

Thanks Whitestrake - this is very much as I suspected - and attempted this with homepage without success. Not entirely sure what my Baseurl is meant to be there. Will give it a few more tries.

That said I was looking for a solution which you touched on in your “option 3” from your link.

You said to try using the “reverse_proxy” directive which is what I am doing already without success.

I will try the headers re-write and investigate the replace_response module handler which looks like a lot of work.

I feel that reverse_proxy is such a huge use case particularly with Docker containers being so prevalent today that this would be a standard solution I guess. (Your repsonse is 4 years old, was hoping things may have progressed since then.)

I tested out Traefik which is designed for exactly this use case - but it struggled without sub-domains.

Will test out your links and post back.

Thanks for your response.

You might be looking for https://gethomepage.dev/configs/settings/#base-url, which outlines exactly what it needs you to specify in the config.

It is a lot of work and it requires a very good understanding of the app in question, how to use the tools in your browser and on the command line to identify which links will need to be replaced, and how to write the Caddyfile config to execute those replacements.

While I won’t rule out the possibility someone will help you with that process here on the forums, generally speaking I’d caution you against expecting such detailed assistance. That kind of effort can easily rise to the level of consultant work, beyond the scope of freely volunteered community help.

I don’t say that to dissuade you; we know that process can work, and I hope it does work for you if you start on that road. I just don’t want you to assume we’ll be able to give you in-depth guidance with it.

It cannot generally progress because it requires careful, tailored, individual implementation for each and every unique upstream software, and may even require more customisation for uniquely configured instances of the same upstream app.

To solve this universally would require tremendous effort in maintaining some kind of compatibility library of each app. The maintenance of such a compatibility library would be unfeasible as the list of apps grows and those apps have occasionally breaking updates over time in terms of that configuration.

Traefik and Caddy are incredibly similarly built under-the-hood (Go-based web server, with dynamic configuration capabilities, first-class ACME integration, using a middleware-based approach to routing.)

I’m not aware of any special properties of Traefik that would make it better than Caddy at handling the subfolder problem. Because it’s a logical issue rather than a bug, as I understand it, ANY reverse proxy is fundamentally faced with the same issue when attempting to force an upstream app into a subfolder if the upstream app expects to have the webroot. It’s a very low-level disagreement between the two softwares that must be in harmony in order to function smoothly.

Thanks - can you explain or help me understand then why this fails

handle_path /homarr* {
    reverse_proxy homarr:7575
}

but this works - the same issue as the other containers.

handle  {
   reverse_proxy homarr:7575
}

The docker network appears to be working there and resolving the path issue.

Because in the second version, you’re not pinning it into a subfolder.

You’re effectively solving the issue with option 2.A. from my post.

This is very confusing - some containers appear just fine, while others are blocked 502.

I would have thought that Caddy is simply proxying things and running through the Docker Network rather than the HOST - which is what is being implied by the subfolder issue.

But there is no subfolder issue is it should be the Docker Network.

This is why the Caddy-Docker-Proxy module is so confusing - why does that exist if Caddy should be doing this natively?

Does this module mean that Caddy is NOT in fact using the docker network it is running on?

I don’t generally expect the subfolder problem to cause any 502s.

I got the impression from the way you described the failure in your original post that your issue was solely HTML pages with broken styling and assets.

In future it would be best to avoid generic phrases like “it fails” and use specific descriptions like “it produces broken assets” or “it returns 502 errors”, to ensure it is clear which kind of issue you’re referring to.

I can see no homarr:7575-specific 502s in your log. Most (all?) of them appear to be dial tcp 172.25.0.9:8085: connect: connection refused, which you mention is flatnotes but you have not supplied the full Compose specification for your stack, only Caddy.

I assume the connection refusal is because:

If you want to reverse proxy through the Compose network, you have to target flatnotes:8080 (the port you’ve configured it to listen to inside the container). If you want to reverse proxy directly to the host, then you would target <host IP>:8085 (or host.docker.internal if you have that mapped as an extra_hosts).

Really not sure why we are being told we can not use paths from an external IP to be proxied when this is exactly what it is meant to do?

There is even a WIKI how to do exactly what I am asking from one of the authors of Caddy Matt Holt describing precisely what I am attempting to do.

I can’t really understand why this is no longer meant to be done as it “subfolders” and will break the paths - yet this wiki describes exactly that.

Just trying to wrap my head around why we are meant to use sub domains now and not paths - and why paths wont work etc

How has this changed ?

Is there an alternative system that I could approach this with?

Thanks in advance.

Are you referring to this part?

There’s one major difference, actually. A huge difference.

That example config isn’t stripping the URI prefix, whereas handle_path does. That means for both upstreams, the request includes the /service-X/ prefix. In turn that means, by necessity, both upstreams must have been configured to expect that prefix and respond appropriately.

To be absolutely unambiguous here, with Matt’s example, you make a request to example.com/service-a/foo and Caddy proxies that request to 192.168.0.2:8001/service-a/foo. With YOUR config, you’re trying to make a request to 144.6.86.11/homarr/foo and have Caddy proxy to homarr:7575/foo. Did you note the missing /homarr prefix? You’ve configured Caddy to hide that part from the upstream app, so it has no idea it’s there. The app only sees Caddy asking for /foo.

As I’ve explained, the subfolder problem arises when you try to “trick” an upstream app to put it in a subfolder and that upstream app isn’t properly configured to do so. It’s a logic disagreement between the web server and the upstream app.

There is no inconsistency here, and our advice has never changed, only your understanding of it.

Caddy documentation even references the wiki post regarding the subfolder problem.

A full Caddyfile example, where handle_path and handle are mutually exclusive; but, be aware of the subfolder problem

handle_path (Caddyfile directive) — Caddy Documentation

I wish I could make a recommendation, but to the honest, absolute best of my knowledge, I am not aware of ANY software which can automatically resolve subfolder-related proxy/upstream conflicts.

The closest I can think of is that Apache httpd has a ProxyPassReverse directive which fixes specifically Location headers somewhat automatically. Caddy has no specific syntactic sugar to make this happen, but it can be done with a header_down rewrite.

ProxyPassReverse very explicitly does not fix URLs in assets specified in HTML as it is not a HTML filter. That is what the custom module caddyserver/replace-response is for in our case, and I’m not sure what the equivalent is in Apache but I’m quite HTML filtering is doable in their ecosystem - I just haven’t had to go there, myself.

Paths absolutely can work. I personally have quite a few apps in my mediaserver stack running in subfolders: Tautulli, Sonarr, Radarr, Lidarr, NZBHydra 2, NZBGet, and TubeSync.

I have a few others in that stack that I have not been able/felt it necessary to configure to play nicely in a subfolder, though: Maintainerr, Heimdall, Plex, CloudTorrent, and Overseerr.