Use env variables #118
Unanswered
danielo515
asked this question in
Questions
Replies: 2 comments 1 reply
-
Hey, sounds good! |
Beta Was this translation helpful? Give feedback.
0 replies
-
Cool. version: '3'
services:
traefik:
image: traefik:latest
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
- proxy
ports:
- 80:80
- 443:443
environment:
- CF_API_EMAIL=${CF_API_EMAIL}
- CF_DNS_API_TOKEN=${CF_DNS_API_TOKEN}
- DOMAIN=${DOMAIN}
# - CF_API_KEY=YOU_API_KEY
# be sure to use the correct one depending on if you are using a token or key
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./data/traefik.yml:/traefik.yml:ro
- ./data/acme.json:/acme.json
- ./data/config.yml:/config.yml:ro
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.entrypoints=http"
- "traefik.http.routers.traefik.rule=Host(`traefik-dashboard.${DOMAIN}`)"
- "traefik.http.middlewares.traefik-auth.basicauth.users=${BASIC_USER}:${BASIC_AUTH}"
- "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https"
- "traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https"
- "traefik.http.routers.traefik.middlewares=traefik-https-redirect"
- "traefik.http.routers.traefik-secure.entrypoints=https"
- "traefik.http.routers.traefik-secure.rule=Host(`traefik-dashboard.${DOMAIN}`)"
- "traefik.http.routers.traefik-secure.middlewares=traefik-auth"
- "traefik.http.routers.traefik-secure.tls=true"
- "traefik.http.routers.traefik-secure.tls.certresolver=cloudflare"
- "traefik.http.routers.traefik-secure.tls.domains[0].main=${DOMAIN}"
- "traefik.http.routers.traefik-secure.tls.domains[0].sans=*.${DOMAIN}"
- "traefik.http.routers.traefik-secure.service=api@internal"
networks:
proxy:
external: true And this is the example DOMAIN=example.com
TZ=Europe/Madrid
BASIC_USER=nobody
BASIC_AUTH='use generate-auth.sh but remove escaping'
CF_DNS_API_TOKEN=your_api_token
CF_API_EMAIL=nobody@gmail.com The reason I am also passing some http:
#region routers
routers:
proxmox:
entryPoints:
- "https"
rule: 'Host(`proxmox.{{env "DOMAIN" }}`)'
middlewares:
- default-headers
- https-redirectscheme
tls: {}
service: proxmox What do you think? Do you like it? For now, I have a |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello.
I think it will be a lot easier to reuse the templase if you just use env variables rather than text placeholders. You can even include an example
.env
file where you just have to put all the configurations variables and then use that env file on the docker compose which in turn will pass it down to traefik and all the services.What do you think?
Beta Was this translation helpful? Give feedback.
All reactions