Last active
May 7, 2020 23:05
-
-
Save jodykpw/246fd37d5ab9142239c62eec741e9ce6 to your computer and use it in GitHub Desktop.
Basic Traefik reverse proxy with Docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
# The reverse proxy service (Traefik) | |
reverse-proxy: | |
# The official v2.2 Traefik docker image | |
image: "traefik:v2.2" | |
container_name: traefik | |
restart: unless-stopped | |
# Static Configuration CLI | |
# Ref: https://docs.traefik.io/reference/static-configuration/cli/ | |
command: | |
- "--log.level=DEBUG" | |
- "--log.format=json" | |
- "--api.insecure=true" | |
- "--providers.docker=true" | |
- "--providers.docker.exposedbydefault=false" | |
- "--entrypoints.web.address=:80" | |
# Dynamic Configuration | |
# command: --configFile=/etc/traefik/traefik.yml | |
ports: | |
# Expose 80 for inbound HTTP traffic. | |
- "80:80" | |
# Expose 443 for inbound HTTPS traffic. | |
# - "443:443" | |
# The Web UI (enabled by --api.insecure=true) | |
- "8080:8080" | |
networks: | |
- traefik | |
volumes: | |
# So that Traefik can listen to the Docker events | |
- "/var/run/docker.sock:/var/run/docker.sock:ro" | |
# Mount the directory containing the configuration file | |
# - "data/config/traefik.yml:/etc/traefik/traefik.yml" | |
# Mount the directory containing the dynamic configuration file | |
# - "data/config/dynamic.config.yml:/etc/traefik/dynamic.config.yml" | |
# Mount the directory containing the certs | |
# - "data/certs:/etc/certs" | |
whoami: | |
image: "containous/whoami" | |
container_name: "simple-service" | |
networks: | |
- traefik | |
labels: | |
# Dynamic configuration with Docker Labels | |
# Ref: https://docs.traefik.io/reference/dynamic-configuration/docker/ | |
- traefik.enable=true | |
- traefik.http.routers.whoami-web.rule=Host(`whoami.domain.com`) | |
- traefik.http.routers.whoami-web.entrypoints=web | |
# if you have multiple ports exposed on the service, specify port in the web-secure service | |
- traefik.http.services.whoami-web-secure.loadbalancer.server.port=80 | |
volumes: | |
data: {} | |
networks: | |
traefik: | |
external: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment