title: Traefik Reverse Proxy with Letsencrypt Docker Compose
body: <p>I bought a domain from Google Domains. I changed the DNS records to cloudflare. I then made an <code>.htpasswd</code> file and saved it to <code>/docker/shared/</code> I also made a <code>rules.toml</code> file located at <code>/etc/traefik/rules.toml</code> I placed nothing inside of this file.</p>
  
  <p>I have a file located at <code>/docker/traefik/traefik.toml</code> this file has the following in it (I changed EMAIL and DOMAIN to mine):</p>
  
  <pre><code>#debug = true
  
  logLevel = "ERROR" #DEBUG, INFO, WARN, ERROR, FATAL, PANIC
  InsecureSkipVerify = true 
  defaultEntryPoints = ["https", "http"]
  
  # WEB interface of Traefik - it will show web page with overview of frontend and backend configurations 
  [web]
  address = ":8080"
    [web.auth.basic]
    usersFile = "/shared/.htpasswd"
  
  # Force HTTPS
  [entryPoints]
    [entryPoints.http]
    address = ":80"
      [entryPoints.http.redirect]
      entryPoint = "https"
    [entryPoints.https]
    address = ":443"
      [entryPoints.https.tls]
  
  [file]
    watch = true
    filename = "/etc/traefik/rules.toml"
  
  # Let's encrypt configuration
  [acme]
  email = "email@domain.com" #any email id will work
  storage="/etc/traefik/acme/acme.json"
  entryPoint = "https"
  acmeLogging=true 
  onDemand = false #create certificate when container is created
  [acme.dnsChallenge]
    provider = "cloudflare"
    delayBeforeCheck = 0
  [[acme.domains]]
     main = "EXAMPLE.COM"
  [[acme.domains]]
     main = "*.EXAMPLE.COM"
  
  # Connection to docker host system (docker.sock)
  [docker]
  endpoint = "unix:///var/run/docker.sock"
  domain = "EXAMPLE.COM"
  watch = true
  # This will hide all docker containers that don't have explicitly  
  # set label to "enable"
  exposedbydefault = false
  </code></pre>
  
  <p>Here is my docker-compose file:</p>
  
  <pre><code>version: "3.6"
  services:
  
    portainer:
      image: portainer/portainer
      container_name: portainer
      restart: always
      command: --templates http://templates/templates.json
      ports:
        - "9000:9000"
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
        - ${USERDIR}/docker/portainer/data:/data
        - ${USERDIR}/docker/shared:/shared
      environment:
        - TZ=${TZ}
  
    watchtower:
      container_name: watchtower
      restart: always
      image: v2tec/watchtower
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
      command: --schedule "0 0 4 * * *" --cleanup
  
    netdata:
      container_name: vigilant_aryabhata
      restart: always
      image: titpetric/netdata
      ports:
        - "19999:19999"
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
      environment:
        - TZ=${TZ}
    traefik:
      hostname: traefik
      image: traefik:latest
      container_name: traefik
      restart: always
      domainname: ${DOMAINNAME}
      networks:
  #      - default
        - traefik_proxy
      ports:
        - "80:80"
        - "443:443"
  #      - "8080:8080"
      environment:
        - CLOUDFLARE_EMAIL=${CLOUDFLARE_EMAIL}
        - CLOUDFLARE_API_KEY=${CLOUDFLARE_API_KEY}
      labels:
        - "traefik.enable=true"
        - "traefik.backend=traefik"
  #      - "traefik.frontend.rule=Host:traefik.${DOMAINNAME}"
        - "traefik.frontend.rule=Host:${DOMAINNAME}; PathPrefixStrip: /traefik"
        - "traefik.port=8080"
        - "traefik.docker.network=traefik_proxy"
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
        - ${USERDIR}/docker/traefik:/etc/traefik
        - ${USERDIR}/docker/shared:/shared
  
  networks:
     traefik_proxy:
       external:
         name: traefik_proxy
     default:
       driver: bridge
  </code></pre>
  
  <p>I then run:</p>
  
  <pre><code>docker-compose -f ${USERDIR}/docker/docker-compose.yml up -d
  </code></pre>
  
  <p>And then I run:</p>
  
  <pre><code>steve@TeamAmerica-PlexServer:~/docker$ docker-compose logs -tf --tail="50" 
  </code></pre>
  
  <p>Which then gives me the following error:</p>
  
  <pre><code>traefikAttaching to traefik
  traefik       | 2018-07-08T01:15:14.506938691Z time="2018-07-08T01:15:14Z" level=error msg="Error starting provider *file.Provider: error reading configuration file: /etc/traefik/rules.toml - open /etc/traefik/rules.toml: no such file or directory"
  </code></pre>
  
  <p>From here I don't really know what to do.</p>