Reverse proxy for subpath doesn't work when redirected to docker container

1. Caddy version:

v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=

2. How I installed, and run Caddy:

docker

a. System environment:

Debian testing, amd64, Docker version 20.10.5+dfsg1, build 55c4c88

b. Command:

Paste command here.

c. Service/unit/compose file:


---
version: '3.5'

networks:
  homelab:
    external: true

services:

  caddy:
    image: tunguskacc/caddy
    build:
      context: "/etc/caddy"
      dockerfile: Dockerfile
    container_name: caddy
    restart: unless-stopped
    networks:
      - homelab
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ${CADDY_CONFIG_FILE}:/etc/caddy/Caddyfile
      - ${CADDY_DATA}:/data
      - ${CADDY_CONFIG}:/config
    extra_hosts:
      - host.docker.internal:host-gateway
    environment:
      - CADDY_INGRESS_NETWORKS=homelab

d. My complete Caddy config:

{
debug
}
  https://server.domain.cc {

    reverse_proxy /service/* docker_container:8080
}

3. The problem I’m having:

The caddyfile above doesn’t work, I get a 200 but zero bytes. SSL certificates are in place. Caddy is never reached, it seems. If I change the subpath and move it to the root domain, removing the subpath in the reverse proxy line, it works.

4. Error messages and/or full log output:

{"level":"info","ts":1675087848.176987,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
{"level":"warn","ts":1675087848.1777902,"msg":"Caddyfile input is not formatted; run the 'caddy fmt' command to fix inconsistencies","adapter":"caddyfile","file":"/etc/caddy/Caddyfile","line":2}
{"level":"info","ts":1675087848.1785684,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]}
{"level":"info","ts":1675087848.1787937,"logger":"http","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"srv0","https_port":443}
{"level":"info","ts":1675087848.178844,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
{"level":"info","ts":1675087848.1791058,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc00046a2a0"}
{"level":"info","ts":1675087848.1793704,"logger":"http","msg":"enabling HTTP/3 listener","addr":":443"}
{"level":"debug","ts":1675087848.1795018,"logger":"http","msg":"starting server loop","address":"[::]:443","tls":true,"http3":true}
{"level":"info","ts":1675087848.1795144,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
{"level":"debug","ts":1675087848.1795428,"logger":"http","msg":"starting server loop","address":"[::]:80","tls":false,"http3":false}
{"level":"info","ts":1675087848.1795504,"logger":"http.log","msg":"server running","name":"remaining_auto_https_redirects","protocols":["h1","h2","h3"]}
{"level":"info","ts":1675087848.1795542,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["server.domain.cc"]}
{"level":"debug","ts":1675087848.179817,"logger":"tls","msg":"loading managed certificate","domain":"server.domain.cc","expiration":1682850708,"issuer_key":"acme-v02.api.letsencrypt.org-directory","storage":"FileStorage:/data/caddy"}
{"level":"debug","ts":1675087848.1800518,"logger":"tls.cache","msg":"added certificate to cache","subjects":["server.domain.cc"],"expiration":1682850708,"managed":true,"issuer_key":"acme-v02.api.letsencrypt.org-directory","hash":"ac4a72981cf3acf7e23a6c63090ec3456497571286c91f194cc82b332def58d8","cache_size":1,"cache_capacity":10000}
{"level":"debug","ts":1675087848.1800716,"logger":"events","msg":"event","name":"cached_managed_cert","id":"08a88ecb-8cdf-4532-9219-63c69db3dc20","origin":"tls","data":{"sans":["server.domain.cc"]}}
{"level":"info","ts":1675087848.1801488,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/data/caddy"}
{"level":"info","ts":1675087848.1802008,"msg":"autosaved config (load with --resume flag)","file":"/config/caddy/autosave.json"}
{"level":"info","ts":1675087848.1802218,"msg":"serving initial configuration"}
{"level":"info","ts":1675087848.1812024,"logger":"tls","msg":"finished cleaning storage units"}

5. What I already tried:

Changing the subpath to a subdomain - works.
Changing subpath to root doamin - works.
No subpath configuration works.

6. Links to relevant resources:

Show an example request with curl -v.

Keep in mind, that many apps don’t behave well when being proxied in a subpath. See this article:

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