Skip to content

Instantly share code, notes, and snippets.

@alexzorin
Last active December 6, 2020 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexzorin/f856d54d228ca4ca1abdca41c7d89f72 to your computer and use it in GitHub Desktop.
Save alexzorin/f856d54d228ca4ca1abdca41c7d89f72 to your computer and use it in GitHub Desktop.
version: '3.7'
services:
traefik:
image: traefik:chevrotin
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "80:80"
- "443:443"
command:
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --providers.docker=true
- --certificatesresolvers.le.acme.caserver=https://acme-v02.api.letsencrypt.org/directory
- --certificatesresolvers.le.acme.email=EMAIL@REPLACE.ME.EXAMPLE.COM
- --certificatesresolvers.le.acme.storage=/acme.json
- --certificatesresolvers.le.acme.tlschallenge=true
labels:
- "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
- "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"
volumes:
- /PATH/TO/ACME.JSON/ON/HOST/REPLACE/ME/acme.json:/acme.json
- /var/run/docker.sock:/var/run/docker.sock:ro
web:
image: nginx:latest
restart: unless-stopped
ports:
- "8080:80"
labels:
- "traefik.http.routers.web.rule=Host(`DOMAIN.NAME.REPLACE.ME.EXAMPLE.COM`)"
- "traefik.http.routers.web.entrypoints=websecure"
- "traefik.http.routers.web.tls=true"
- "traefik.http.routers.web.tls.certresolver=le"
db:
image: mariadb:latest
restart: unless-stopped
labels:
- "traefik.backend=db"
- "traefik.enable=false"
ports:
- 3306
environment:
MYSQL_USER: someuser
MYSQL_DATABASE: somedb
MYSQL_PASSWORD: some_pwd
MYSQL_ROOT_PASSWORD: some_other_pwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment