Skip to content

Instantly share code, notes, and snippets.

@PhilipSchmid
Last active August 27, 2019 09:21
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 PhilipSchmid/e26ccb74f3d5fcce7499143524038757 to your computer and use it in GitHub Desktop.
Save PhilipSchmid/e26ccb74f3d5fcce7499143524038757 to your computer and use it in GitHub Desktop.

Let's Encrypt Traefik Docker Compose Example

version: "3.7"

services:
  lb:
    image: index.docker.io/traefik:v1.7.14-alpine
    hostname: traefik-webserver.example.com
    restart: unless-stopped
    environment:
      TZ: Europe/Zurich
    ports:
      - 80:80
      - 443:443
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /opt/traefik:/acme
    command: >
      --api.dashboard=false
      --logLevel=WARN
      --entryPoints='Name:http Address::80 Redirect.EntryPoint:https'
      --entryPoints='Name:https Address::443 TLS TLS.MinVersion:VersionTLS12 TLS.CipherSuites:TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256'
      --defaultentrypoints='http,https'
      --acme
      --acme.email='servicedesk@example.com'
      --acme.entrypoint='https'
      --acme.tlschallenge=true
      --acme.onhostrule=true
      --acme.storage='/acme/acme.json'
      --docker
      --docker.domain='example.com'
      --docker.exposedbydefault=false
    networks:
      external:
      transit_httpd_external:

  webserver:
    image: index.docker.io/httpd:2.4.41-alpine
    hostname: webapp.example.com
    restart: unless-stopped
    environment:
      TZ: Europe/Zurich
    depends_on:
      - lb
    networks:
      transit_httpd_external:
    labels:
      traefik.enable: 'true'
      traefik.port: 80
      traefik.frontend.rule: Host:webapp.example.com
      traefik.protocol: http
      # Only required if this service would have 2 networks or more:
      traefik.docker.network: transit_httpd_external

networks:
  external:
  transit_httpd_external:
    external: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment