lucaslorentz / caddy-docker-proxy

Caddy as a reverse proxy for Docker
MIT License
2.86k stars 168 forks source link

Empty label caddy.reverse_proxy.transport.tls_insecure_skip_verify not expanding correctly #575

Closed herlev closed 8 months ago

herlev commented 8 months ago

I am trying to setup caddy-docker-proxy as a reverse proxy for unifi-controller, so probably related to #329. I am trying to recreate the following Caddyfile, which works as intended, using labels in docker-compose.yml.

http://unifi.home.lan {
    request_header -Referer
    request_header -Origin
    reverse_proxy https://CONTAINER_IP:8443 {
        transport http {
            tls_insecure_skip_verify
        }
    }
}

The following labels inside docker-compose.yml are what I am trying to generate the above with.

labels:
  caddy: http://unifi.home.lan
  caddy.reverse_proxy: "{{upstreams https 8443}}"
  caddy.reverse_proxy.transport: http
  caddy.reverse_proxy.transport.tls_insecure_skip_verify:

This does not work as intended. Looking at the routes from /config/caddy/autosave.json inside the container, we can see that the generated config is not as expected:

{
  "handle":[
    {
      "handler":"subroute",
      "routes":[
        {
          "handle":[
            {
              "handler":"reverse_proxy",
              "transport":{
                "protocol":"http",
                "tls":{

                }
              },
              "upstreams":[
                {
                  "dial":"172.19.0.7:8443"
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "match":[
    {
      "host":[
        "unifi.home.lan"
      ]
    }
  ],
  "terminal":true
}

The expected value of tls would be:

"tls":{
    "insecure_skip_verify":true
}   

I have tried with all of the following labels, but none of them seems to work as intended.

caddy.reverse_proxy.transport.tls_insecure_skip_verify:
caddy.reverse_proxy.transport.tls_insecure_skip_verify: ""
caddy.reverse_proxy.transport.tls_insecure_skip_verify: {{""}}
herlev commented 8 months ago

The issue seems to be that I was starting the container from Dockge, instead of doing docker-compose up -d. Apparently these are not doing the same thing.