mirror of
https://github.com/nickyeoman/docker-compose-cookbooks.git
synced 2026-09-04 02:46:23 +00:00
45 lines
1.6 KiB
YAML
45 lines
1.6 KiB
YAML
###############################################################################
|
|
# docker-compose up -d
|
|
###############################################################################
|
|
|
|
version: '3.3'
|
|
|
|
networks:
|
|
web:
|
|
driver: bridge
|
|
|
|
services:
|
|
|
|
traefik:
|
|
image: "traefik:v2.1.3"
|
|
container_name: "traefik"
|
|
restart: unless-stopped
|
|
command:
|
|
- --entrypoints.web.address=:80
|
|
- --entrypoints.websecure.address=:443
|
|
- --api
|
|
- --providers.docker
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
- "/var/run/docker.sock:/var/run/docker.sock:ro"
|
|
networks:
|
|
- web
|
|
labels:
|
|
# Dashboard
|
|
- "traefik.http.routers.traefik.rule=Host(`proxy.nickyeoman.com`)"
|
|
- "traefik.http.routers.traefik.service=api@internal"
|
|
- "traefik.http.routers.traefik.tls.certresolver=leresolver"
|
|
- "traefik.http.routers.traefik.entrypoints=websecure"
|
|
- "traefik.http.routers.traefik.middlewares=authtraefik"
|
|
# https://medium.com/@techupbusiness/add-basic-authentication-in-docker-compose-files-with-traefik-34c781234970
|
|
# echo $(htpasswd -nbB <USER> "<PASS>") | sed -e s/\\$/\\$\\$/g
|
|
- "traefik.http.middlewares.authtraefik.basicauth.users=nick:encryptedpasswordgoeshere"
|
|
# 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"
|