caddy-docker-proxy icon indicating copy to clipboard operation
caddy-docker-proxy copied to clipboard

cannot get auto_https turned off using docker labels

Open jmls opened this issue 10 months ago • 2 comments

I am trying to have a compose project running with caddy-docker-proxy, not using auto_https , and am struggling. This is my compose file, and I am not sure exactly what I am missing or need to do

  caddy:
    image: lucaslorentz/caddy-docker-proxy:ci-alpine
    ports:
      - '8081:80'
    labels:
      - auto_https=off
    environment:
      - CADDY_INGRESS_NETWORKS=app-network
    networks:
      app-network: 
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /workspace/caddy:/data
    restart: unless-stopped
  whoami:
    image: traefik/whoami
    labels:
      - caddy.handle_path=/whoami/*
      - caddy.reverse_proxy={{upstreams 80}}
    networks:
      app-network: 


this compose is running behind a ssl proxy (technically, I#m running in a gitpod workspace) so my url is

https://8081-my-project-hn2cugzjzzl.ws-eu117.gitpod.io

which sends traffic to port 8081 (caddy).

I do not want https on the whoami container (or any other service in the stack)

what I want to do is enter this url

https://8081-my-project-hn2cugzjzzl.ws-eu117.gitpod.io/whoami

and for caddy-docker to proxy to the whoamu container

I just can't seem to get the labels right to make this happen. For example the above config give these errors. I really would appreciate someone pointing out the glaringly obvious mistakes ;)

{"level":"info","ts":1737890912.8091004,"logger":"docker-proxy","msg":"Running caddy proxy server"}
{"level":"info","ts":1737890912.8101244,"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":1737890912.8103492,"msg":"autosaved config (load with --resume flag)","file":"/config/caddy/autosave.json"}
{"level":"info","ts":1737890912.8103623,"logger":"docker-proxy","msg":"Running caddy proxy controller"}
{"level":"info","ts":1737890912.810923,"logger":"docker-proxy","msg":"Start","CaddyfilePath":"","EnvFile":"","LabelPrefix":"caddy","PollingInterval":30,"ProxyServiceTasks":true,"ProcessCaddyfile":true,"ScanStoppedContainers":false,"IngressNetworks":"[app-network]","DockerSockets":[""],"DockerCertsPath":[""],"DockerAPIsVersion":[""]}
{"level":"info","ts":1737890912.8115444,"logger":"docker-proxy","msg":"Connecting to docker events","DockerSocket":""}
{"level":"info","ts":1737890912.8136897,"logger":"docker-proxy","msg":"IngressNetworksMap","ingres":"map[]"}
{"level":"info","ts":1737890912.8247716,"logger":"docker-proxy","msg":"Swarm is available","new":false}
{"level":"info","ts":1737890912.8300862,"logger":"docker-proxy","msg":"New Caddyfile","caddyfile":"# Empty caddyfile"}
{"level":"warn","ts":1737890912.830408,"logger":"docker-proxy","msg":"Caddyfile to json warning","warn":"[Caddyfile:1: Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies]"}
{"level":"info","ts":1737890912.8304245,"logger":"docker-proxy","msg":"New Config JSON","json":"{}"}
{"level":"info","ts":1737890912.8304708,"logger":"docker-proxy","msg":"Sending configuration to","server":"localhost"}
{"level":"info","ts":1737890912.831213,"logger":"admin.api","msg":"received request","method":"POST","host":"localhost:2019","uri":"/load","remote_ip":"127.0.0.1","remote_port":"47122","headers":{"Accept-Encoding":["gzip"],"Content-Length":["41"],"Content-Type":["application/json"],"User-Agent":["Go-http-client/1.1"]}}
{"level":"info","ts":1737890912.8312547,"msg":"config is unchanged"}
{"level":"info","ts":1737890912.8312595,"logger":"admin.api","msg":"load complete"}
{"level":"info","ts":1737890912.8313375,"logger":"docker-proxy","msg":"Successfully configured","server":"localhost"}
{"level":"warn","ts":1737890912.971588,"logger":"docker-proxy","msg":"Container is not in same network as caddy","container":"34cdef5c06b950529a9c554dd0d46c0364836bc23d554941067c75978b9691b7","container id":"34cdef5c06b950529a9c554dd0d46c0364836bc23d554941067c75978b9691b7"}
{"level":"info","ts":1737890912.971706,"logger":"docker-proxy","msg":"Process Caddyfile","logs":"[ERROR]  Removing invalid block: Caddyfile:2: unrecognized global option: handle_path\n{\n\thandle_path /whoami/*\n\treverse_proxy\n}\n\n"}
{"level":"warn","ts":1737890913.305647,"logger":"docker-proxy","msg":"Container is not in same network as caddy","container":"34cdef5c06b950529a9c554dd0d46c0364836bc23d554941067c75978b9691b7","container id":"34cdef5c06b950529a9c554dd0d46c0364836bc23d554941067c75978b9691b7"}
{"level":"info","ts":1737890913.3057563,"logger":"docker-proxy","msg":"Process Caddyfile","logs":"[ERROR]  Removing invalid block: Caddyfile:2: unrecognized global option: handle_path\n{\n\thandle_path /whoami/*\n\treverse_proxy\n}\n\n"}
{"level":"warn","ts":1737890928.5248384,"logger":"docker-proxy","msg":"Container is not in same network as caddy","container":"34cdef5c06b950529a9c554dd0d46c0364836bc23d554941067c75978b9691b7","container id":"34cdef5c06b950529a9c554dd0d46c0364836bc23d554941067c75978b9691b7"}
{"level":"info","ts":1737890928.5249677,"logger":"docker-proxy","msg":"Process Caddyfile","logs":"[ERROR]  Removing invalid block: Caddyfile:2: unrecognized global option: handle_path\n{\n\thandle_path /whoami/*\n\treverse_proxy\n}\n\n"}
gitpod /workspace/portal (develop) $ 

jmls avatar Jan 26 '25 11:01 jmls

Please re-read the README. All labels must start with caddy. so that it knows which labels are for Caddy config or for something else. https://github.com/lucaslorentz/caddy-docker-proxy?tab=readme-ov-file#labels-to-caddyfile-conversion

francislavoie avatar Jan 26 '25 14:01 francislavoie

ah, crap - I have caddy.* in the whoami, missed the one in caddy. will retry, thanks

jmls avatar Jan 26 '25 15:01 jmls

Hitting this, seems like caddy.auto_https: off doesn't work in the caddy service, I have to set the http:// protocol on the individual service as per this comment: https://github.com/lucaslorentz/caddy-docker-proxy/issues/336#issuecomment-1025655093

pthieu avatar Aug 06 '25 16:08 pthieu

Still an issue, doesn't seem to work with caddy.auto_https: off. Getting invalid config, removing property when running with it

arjendevos avatar Oct 08 '25 18:10 arjendevos