Skip to content

Instantly share code, notes, and snippets.

@LordotU
Created December 20, 2019 22:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LordotU/c6e957b2c1ff2f91a491f95bfc5308f5 to your computer and use it in GitHub Desktop.
Save LordotU/c6e957b2c1ff2f91a491f95bfc5308f5 to your computer and use it in GitHub Desktop.
Traefik 1.7.* as Reverse Proxy And Let's Encrypt
# This file should be empty and its permission should be 600
version: '3'
services:
<backend_1>:
image: nginx
container_name: traefik-<backend_1>
volumes:
- "<path_to_hostname_nginx_conf>:/etc/nginx/conf.d/default.conf:ro" # in case of using nginx (with cusom config) for backend
labels:
- traefik.backend=<backend_1>
- traefik.frontend.rule=Host:<backend_1_domain>,<backend_1_domain_alias>
- traefik.docker.network=web
- traefik.port=<backend_1_port>
# ...
# <backend_N>:
# image: nginx
# container_name: traefik-<backend-N>
# volumes:
# - "<path_to_hostname_nginx_conf>:/etc/nginx/conf.d/default.conf:ro"
# labels:
# - traefik.backend=<backend_N>
# - traefik.frontend.rule=Host:<backend_N_domain>,<backend_N_domain_alias>
# - traefik.docker.network=web
# - traefik.port=<backend_N_port>
# web should be created earlier via command: docker network create web
networks:
default:
external:
name: web
version: '3'
services:
traefik:
image: traefik:maroilles-alpine
container_name: traefik
ports:
- "80:80"
- "443:443"
volumes:
- "./traefik.toml:/traefik.toml"
- "./acme.json:/acme.json"
- "/var/run/docker.sock:/var/run/docker.sock"
labels:
- "traefik.frontend.rule=Host:traefik.<domain>"
- "traefik.port=8080"
# web should be created earlier via command: docker network create web
networks:
default:
external:
name: web
defaultEntryPoints = ["http", "https"]
[entryPoints]
[entryPoints.dashboard]
address = ":8080"
[entryPoints.dashboard.auth]
[entryPoints.dashboard.auth.basic]
users = ["<your_username>:<your_encrypted_password>"]
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
permament = true
[entryPoints.https]
address = ":443"
[entryPoints.https.redirect]
regex = "^https://www.(.*)"
replacement = "https://$1"
permanent = true
[entryPoints.https.tls]
[api]
entrypoint="dashboard"
[acme]
email = "<your_email>"
storage = "acme.json"
entryPoint = "https"
onHostRule = true
[acme.httpChallenge]
entryPoint = "http"
[docker]
watch = true
network = "web"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment