feat: implement the traefik plugin
This plugin uses a docker-compose based Traefik installation in conjunction with injected container labels to route requests. It only exposes the minimal necessary for routing traffic to docker containers. Users wishing to customize further labels may explore using the docker-options plugin to attach additional labels during the 'deploy' phase.
This commit is contained in:
54
plugins/traefik-vhosts/templates/compose.yml.sigil
Normal file
54
plugins/traefik-vhosts/templates/compose.yml.sigil
Normal file
@@ -0,0 +1,54 @@
|
||||
---
|
||||
version: "3.3"
|
||||
|
||||
services:
|
||||
traefik:
|
||||
image: "{{ $.TRAEFIK_IMAGE }}"
|
||||
command:
|
||||
- --entrypoints.web.address=:80
|
||||
- --entrypoints.websecure.address=:443
|
||||
- --providers.docker
|
||||
- --api={{ $.TRAEFIK_API_ENABLED }}
|
||||
- --api.dashboard={{ $.TRAEFIK_DASHBOARD_ENABLED }}
|
||||
|
||||
- --log.level={{ $.TRAEFIK_LOG_LEVEL }}
|
||||
- --log.format=json
|
||||
|
||||
{{ if $.TRAEFIK_LETSENCRYPT_EMAIL }}
|
||||
- --certificatesresolvers.leresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
- --certificatesresolvers.leresolver.acme.email={{ $.TRAEFIK_LETSENCRYPT_EMAIL }}
|
||||
- --certificatesresolvers.leresolver.acme.storage=/acme.json
|
||||
- --certificatesresolvers.leresolver.acme.tlschallenge=true
|
||||
{{ end }}
|
||||
|
||||
labels:
|
||||
# Dashboard
|
||||
- "traefik.http.routers.api.rule=Host(`{{ $.TRAEFIK_API_VHOST }}`)"
|
||||
- "traefik.http.routers.api.service=api@internal"
|
||||
- "traefik.http.routers.api.entrypoints=web{{ if $.TRAEFIK_LETSENCRYPT_EMAIL }}secure{{ end }}"
|
||||
- "traefik.http.routers.middlewares=auth"
|
||||
{{ if $.TRAEFIK_BASIC_AUTH }}
|
||||
- "traefik.http.middlewares.auth.basicauth.users={{ $.TRAEFIK_BASIC_AUTH }}"
|
||||
{{ end }}
|
||||
|
||||
{{ if $.TRAEFIK_LETSENCRYPT_EMAIL }}
|
||||
- "traefik.http.routers.api.tls.certresolver=leresolver"
|
||||
|
||||
# global redirect to https
|
||||
- "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
|
||||
- "traefik.http.routers.http-catchall.entrypoints=web"
|
||||
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
|
||||
|
||||
# middleware redirect
|
||||
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
|
||||
{{ end }}
|
||||
|
||||
network_mode: bridge
|
||||
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
|
||||
volumes:
|
||||
- "/var/run/docker.sock:/var/run/docker.sock:ro"
|
||||
- "{{ $.TRAEFIK_DATA_DIR }}/traefik-acme.json:/acme.json"
|
||||
Reference in New Issue
Block a user