Skip to content

Instantly share code, notes, and snippets.

@heralight
Last active November 5, 2022 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heralight/f3680480e2fdff3167f341b5bb16d5f8 to your computer and use it in GitHub Desktop.
Save heralight/f3680480e2fdff3167f341b5bb16d5f8 to your computer and use it in GitHub Desktop.
Rancher 2.6 traefik and docker-compose with let's encrypt namecheap DNS-01 challenge
version: "3.3"
services:
traefik:
image: "traefik:v2.9"
container_name: "traefik"
command:
- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.myresolver.acme.dnschallenge=true"
- "--certificatesresolvers.myresolver.acme.dnschallenge.provider=namecheap"
- "--certificatesresolvers.myresolver.acme.dnschallenge.resolvers=dns1.registrar-servers.com:53,dns2.registrar-servers.com:53"
#- "--certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
- "--certificatesresolvers.myresolver.acme.email=postmaster@example.com"
- "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
- "--global.sendAnonymousUsage=false"
- "--serverstransport.insecureskipverify=true"
restart: always
ports:
- "31080:80"
- "31443:443"
- "38080:8080"
environment:
- "NAMECHEAP_API_KEY=YOURAPIKEY"
- "NAMECHEAP_API_USER=YOURUSERNAME"
volumes:
- "./letsencrypt:/letsencrypt"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
whoami:
image: "traefik/whoami"
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=Host(`yourdomainwhoami.example.com`)"
- "traefik.http.routers.whoami.entrypoints=websecure"
- "traefik.http.routers.whoami.tls.certresolver=myresolver"
profiles:
- donotstart
rancher:
image: rancher/rancher:stable
command: --no-cacerts
#command: --acme-domain yourdomainrancher.example.com
privileged: true
environment:
- "AUDIT_LEVEL=1"
volumes:
- "./local/mysql:/var/lib/mysql"
- "./local/auditlog:/var/log/auditlog"
- "./local/rancher:/var/lib/rancher"
expose:
- 80
- 443
labels:
- "traefik.enable=true"
- "traefik.http.routers.rancher.rule=Host(`yourdomainrancher.example.com`)"
- "traefik.http.services.rancher.loadbalancer.server.port=443"
- "traefik.http.services.rancher.loadbalancer.server.scheme=https"
- "traefik.http.services.rancher.loadbalancer.passhostheader=true"
- "traefik.http.routers.rancher.entrypoints=websecure"
- "traefik.http.routers.rancher.tls.certresolver=myresolver"
- "traefik.http.middlewares.rancher-behind-proxy.headers.customrequestheaders.X-Forwarded-Proto=https"
- "traefik.http.routers.rancher.middlewares=rancher-behind-proxy"
restart: always
@heralight
Copy link
Author

Then docker compose up, wait, and go to https://yourdomainrancher.example.com:31443

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment