acouvreur / sablier

Start your containers on demand, shut them down automatically when there's no activity. Docker, Docker Swarm Mode and Kubernetes compatible.
https://acouvreur.github.io/sablier/
GNU Affero General Public License v3.0
1.16k stars 43 forks source link

Caddyfile parse error: first path segment in URL cannot contain colon #291

Closed valankar closed 2 months ago

valankar commented 2 months ago

Describe the bug Error using Caddy with provided config.

        route /accounts_plotly {
                sablier url=http://localhost:10000 {
                        group accounts
                        session_duration 1m
                        dynamic {
                                display_name Accounts
                        }
                }
                reverse_proxy localhost:8050
        }
Error: loading initial config: loading new config: loading http app module: provision http: server srv0: setting up route handlers: route 6: loading handler modules: position 0: loading module 'subroute': provision http.handlers.subroute: setting up subroutes: route 9: loading handler modules: position 0: loading module 'subroute': provision http.handlers.subroute: setting up subroutes: route 0: loading handler modules: position 0: loading module 'sablier': provision http.handlers.sablier: parse "url=http://localhost:10000/api/strategies/dynamic": first path segment in URL cannot contain colon

My compose file:

  sablier:
    image: acouvreur/sablier
    container_name: sablier
    network_mode: host
    command:
        - start
        - --provider.name=docker
    volumes:
      - '/var/run/docker.sock:/var/run/docker.sock'

My Dockerfile:

FROM caddy:builder AS builder

ADD https://github.com/acouvreur/sablier.git /sablier

RUN xcaddy build \
    --with github.com/caddy-dns/cloudflare \
    --with github.com/lanrat/caddy-dynamic-remoteip \
    --with github.com/WeidiDeng/caddy-cloudflare-ip \
    --with github.com/acouvreur/sablier/plugins/caddy=/sablier/plugins/caddy

FROM caddy:latest

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

Context

Expected behavior I think I'm specifying the config right, but maybe I'm missing something?

valankar commented 2 months ago

I saw in the code this should actually be sablierURL. I made that change and Caddy was able to start properly. Unfortunately I just couldn't get it working with my container. I saw the waiting screen, then redirected to blank page. Interestingly in my access.log it sets the status code to 0 (instead of http codes 200, etc). It also brought down my container, but never brought it back up. I can't really tell from your documentation how to debug this.

acouvreur commented 2 months ago

Hello @valankar,

Can you please give more details on the whole configuration ?

For exemple, make sure that the caddy container itself is not part of the group, otherwise it will be stopping the reverse proxy itself.

All E2E tests are working examples of the caddy reverse proxy, see https://github.com/acouvreur/sablier/tree/main/plugins/caddy/e2e/docker

I see that you are targeting sablier with localhost:1000 from the Caddy middleware. Do you have Caddy on network host and sablier exposing port 10000 to the host ?

valankar commented 2 months ago

Yes I run Caddy with host networking and services listen on localhost, including sablier. I see there is logging.level=trace which might help me narrow it down. I will try again looking at the e2e example.

valankar commented 2 months ago

Ok, I figured out that there is a problem only when using SSL. I'll double check with a released version instead of head and file a bug if I can reproduce.