Skip to content

Instantly share code, notes, and snippets.

@lepinkainen
Last active February 19, 2020 22:41
Show Gist options
  • Save lepinkainen/006f21903e0c54b8e5698096df7147c2 to your computer and use it in GitHub Desktop.
Save lepinkainen/006f21903e0c54b8e5698096df7147c2 to your computer and use it in GitHub Desktop.
Traefik + Caddy + ACME + services + fancy subdomains
version: '2'
services:
caddy:
build: .
labels:
- traefik.enable=true
- traefik.http.routers.caddy.rule=Host(`pier.xyz`)
- traefik.http.routers.caddy.entrypoints=websecure
- traefik.http.routers.caddy.tls.certresolver=mytlschallenge
networks:
- traefik
restart: 'unless-stopped'
networks:
traefik:
external: true
0.0.0.0:80 {
tls off
status 404 /
}
FROM abiosoft/caddy:1.0.3
ENV ACME_AGREE=true
COPY etc /etc
version: '2'
services:
portainer:
image: portainer/portainer
command: -H unix:///var/run/docker.sock
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
labels:
- traefik.enable=true
- traefik.http.routers.portainer.rule=Host(`portainer.pier.xyz`)
- traefik.http.routers.portainer.entrypoints=websecure
- traefik.http.routers.portainer.tls.certresolver=mytlschallenge
networks:
- traefik
volumes:
portainer_data:
networks:
traefik:
external: true
version: '3'
services:
reverse-proxy:
# The official v2.1 Traefik docker image
image: traefik:v2.1
# Enables the web UI and tells Traefik to listen to docker
command:
#- --log.level=DEBUG
- --api=false
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --providers.docker.network=traefik
- --providers.file.directory=/config
- --providers.file.watch=true
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --certificatesresolvers.mytlschallenge.acme.tlschallenge=true
- --certificatesresolvers.mytlschallenge.acme.email=pier@foo
- --certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json
ports:
- 80:80
- 443:443
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./letsencrypt:/letsencrypt
- ./config:/config:ro
labels:
- traefik.enable=true
- traefik.http.routers.http-catchall.rule=hostregexp(`{host:[a-z-.]+}`)
- traefik.http.routers.http-catchall.entrypoints=web
- traefik.http.routers.http-catchall.middlewares=redirect-to-https
- traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https
networks:
- traefik
restart: unless-stopped
networks:
traefik:
external: true
version: '2'
services:
whoami:
image: containous/whoami
container_name: whoami
labels:
- traefik.enable=true
- traefik.http.routers.whoami.rule=Host(`whoami.pier.xyz`)
- traefik.http.routers.whoami.entrypoints=websecure
- traefik.http.routers.whoami.tls.certresolver=mytlschallenge
- traefik.frontend.port=80
networks:
- traefik
restart: 'unless-stopped'
networks:
traefik:
external: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment