Last active
August 6, 2024 16:49
-
-
Save Ali-Flt/0384b9bca2acea4365ada99cedde1fb6 to your computer and use it in GitHub Desktop.
Docker config for traefik. Providers: cloudflare and docker. Challenge: dnsChallenge. App running on port 8008 of service
This file contains 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
Docker config for traefik. Providers: cloudflare and docker. Challenge: dnsChallenge. App running on port 8008 of service |
This file contains 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
HOST_DOMAIN=you.domain.name | |
USER_PASS=XXX # Generate using echo $(htpasswd -nB username) | sed -e s/\\$/\\$\\$/g |
This file contains 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
services: | |
service_name: | |
labels: | |
- "traefik.enable=true" | |
- "traefik.http.routers.router_name.rule=Host(`${HOST_DOMAIN}`)" | |
- "traefik.http.routers.router_name.tls=true" | |
- "traefik.http.routers.router_name.entrypoints=websecure" | |
- "traefik.http.routers.router_name.tls.certresolver=myresolver" | |
- "traefik.http.routers.router_name.service=router_name_service" | |
- "traefik.http.services.router_name_service.loadbalancer.server.port=8008" | |
- "traefik.http.routers.router_name.middlewares=container_name_auth" | |
- "traefik.http.middlewares.container_name_auth.basicauth.users=${USER_PASS}" | |
build: | |
context: . | |
dockerfile: Dockerfile | |
image: image_name:latest | |
expose: | |
- 8008 | |
container_name: container_name | |
user: ${USER} | |
restart: always | |
networks: | |
- traefik-net | |
networks: | |
traefik-net: | |
name: traefik-net | |
external: true |
This file contains 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
services: | |
traefik: | |
image: traefik:v3.1.1 | |
restart: always | |
command: | |
- "--providers.docker=true" | |
- "--entrypoints.web.address=:80" | |
- "--entrypoints.websecure.address=:443" | |
- "--certificatesresolvers.myresolver.acme.email=XXX" | |
- "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json" | |
- "--certificatesresolvers.myresolver.acme.dnsChallenge.provider=cloudflare" | |
ports: | |
- "80:80" | |
- "443:443" | |
volumes: | |
- "/var/run/docker.sock:/var/run/docker.sock:ro" | |
- "./letsencrypt:/letsencrypt" | |
environment: | |
- CF_API_EMAIL=XXX | |
- CF_DNS_API_TOKEN=XXX | |
networks: | |
- traefik-net | |
networks: | |
traefik-net: | |
name: traefik-net | |
external: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment