Skip to content

Instantly share code, notes, and snippets.

@StudioEtrange
Last active January 31, 2022 17:11
Show Gist options
  • Save StudioEtrange/c6bb41732063b0151adf5ef592768348 to your computer and use it in GitHub Desktop.
Save StudioEtrange/c6bb41732063b0151adf5ef592768348 to your computer and use it in GitHub Desktop.
traefik sample for route to an external URL - add a blog.mondomain.com route to http://blog:4000
traefik:
image: traefik:v2.1.6
container_name: traefik
volumes:
- "traefik.enable=true"
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./traefik-conf.yml:/etc/traefik/traefik.yml
- ./traefik-services.yml:/etc/traefik/services.yml
labels:
- "traefik.http.routers.blog.entrypoints=web_main"
- "traefik.http.routers.blog.rule=HostRegexp(`{subdomain:blog}.{domain:moncomain.com}`)"
- "traefik.http.routers.blog.service=blog@file"
networks:
- default
expose:
# web_main entrypoints
- 80
ports:
- 80:80
# NOTE : conf in this file are not cumulative and cancel any option passed to traefik at launch with command in docker compose file
api:
dashboard: true
debug: false
insecure: true
log:
level: "DEBUG"
entryPoints:
web_main:
address: ":80"
providers:
docker:
endpoint: unix:///var/run/docker.sock
# If set to false, containers that don't have a traefik.enable=true label will be ignored from the resulting routing configuration
exposedByDefault: false
file:
filename: /etc/traefik/services.yml
http:
services:
blog:
loadBalancer:
servers:
- url: "http://blog:4000/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment