Skip to content

Traefik and Caddy support #589

@waterkip

Description

@waterkip

What are your opinions about Caddy and Traefik?

I could provide a plug and play system where Traefik terminates SSL and Caddy serves static files.

You essentially define Traefik:

services:
  traefik:
    image: traefik:v3.6
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./etc:/etc/traefik-config
      - ./etc/traefik.yml:/etc/traefik/traefik.yml

You configure Traefik:

logs:
  level: debug

api:
  insecure: true

providers:
  file:
    directory: /etc/traefik-config
    watch: true
  docker:
    exposedbydefault: false

entrypoints:
  web-secure:
    address: :443
  plain-http:
    address: :80
    http:
      redirections:
        entryPoint:
          to: websecure
          scheme: https

You configure Caddy:

  web:
    build:
      context: .
      dockerfile: ./docker/caddy/Dockerfile
    expose:
      - 80
    networks:
      - default
    depends_on:
      pause:
        condition: service_started
    volumes:
      - ./:/var/www:rw
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.web.rule=Host(`pause.localhost`)"
      - "traefik.http.routers.web.entrypoints=websecure"
      - "traefik.http.routers.web.tls=true"
      - "traefik.http.services.web.loadbalancer.server.port=80"
      - "traefik.http.middlewares.https-forward.headers.customrequestheaders.X-Forwarded-Proto=https"
      - "traefik.http.routers.web.middlewares=https-forward"

And the Dockerfile:

$ cat ./docker/caddy/Dockerfile
FROM caddy:2-alpine

COPY ./docker/caddy/Caddyfile /etc/caddy/Caddyfile
WORKDIR /var/www

With a simple Caddyfile:

:80 {
  root * /var/www/public
  file_server
}

If you have mkcert the stuff becomes even easier for the SSL certs.

If you want this, I can work on it, otherwise I'll leave it up so you can think about it :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions