title: Can't hit site with Traefik in Docker
body: <p>I'm new to Docker and newer to Traefik, but I tried going through the documentation, examples, and questions regarding this - and it still doesn't work.</p>
  <p>I have a Raspberry Pi running Linux 4.19.118-v7 on which I've installed Docker. I also have <a href="https://octoprint.org/" rel="nofollow noreferrer">OctoPrint</a> installed as a service which is in a working state. When setup with HAProxy, I have full access to it.</p>
  <p>I tried installing Traefik with Docker, disable HAProxy, and let Traefik handle the connection.
  Traefik works, as I can see its dashboard, but the way I routed everything gives me a <code>Bad Gateway</code> (502) response.</p>
  <p>I can do a <code>curl http://127.0.0.1:5000</code> on the Pi which returns me the page I want, so there's something there, just not accessible with Traefik.</p>
  <p>I have three files responsible:</p>
  <p><strong>Docker-compose.yml</strong></p>
  <pre><code>version: '3.4'
  
  services:
    traefik:
      # The official v2 Traefik docker image
      image: traefik:v2.2.7
      # Enables the web UI and tells Traefik to listen to docker
      command: --providers.docker
      container_name: &quot;traefik&quot;
      ports:
        # The HTTP port
        - &quot;80:80&quot;
        # The Web UI (enabled by --api.insecure=true)
        - &quot;8088:8080&quot;
        # The HTTPS port
        - &quot;443:443&quot;
      volumes:
        # So that Traefik can listen to the Docker events
        - &quot;/var/run/docker.sock:/var/run/docker.sock&quot;
        - &quot;./traefik.yml:/traefik.yml:ro&quot;
        - &quot;./acme.json:/acme.json&quot;
        - &quot;./conf/traefik_dynamic.yml:/conf/traefik_dynamic.yml&quot;
      labels:
        - &quot;traefik.enable=true&quot;
        - &quot;traefik.port=80&quot;
      networks:
        - traefik-network
  
  networks:
    traefik-network:
      external:
        name: traefik_default
  </code></pre>
  <p>I run this with <code>docker -f ./docker-compose.yml up -d</code>.</p>
  <p>It picks up the static configuration file <strong>traefik.yml</strong>:</p>
  <pre><code>## STATIC CONFIGURATION
  log:
    level: DEBUG
  
  api:
    insecure: true
    dashboard: true
  
  entryPoints:
  
    web:
      address: &quot;:80&quot;
  
    webSecure:
      address: &quot;:443&quot;
  
  providers:
    file:
      directory: /conf
      watch: true
  
  certificatesResolvers:
    lets-encr:
      acme:
        #caServer: https://acme-staging-v02.api.letsencrypt.org/directory
        storage: acme.json
        email: myActual@emailNotShown.io
        httpChallenge:
          entryPoint: web
  </code></pre>
  <p>And the dynamic configurations of <strong>conf/trafik_dynamic.yml</strong>:</p>
  <pre><code>http:
  
    routers:
      to-octoprint:
        rule: &quot;Host(`3d.myWebsite.io`)&quot;
        service: octoprint
        entryPoints:
          - web
  
    services:
  
      octoprint:
        loadBalancer:
          servers:
            - url: &quot;http://127.0.0.1:5000&quot;
  
    providers:
      docker: {}
  </code></pre>
  <p>This all result in the <code>Bad Gateway</code> when I try to hit <code>http://3d.myWebsite.io</code> (not my real site, mind you), so I went to the log in Debug mode.
  It spits out 4 lines twice per request:</p>
  <pre><code>msg=&quot;vulcand/oxy/roundrobin/rr: begin ServeHttp on request&quot; Request=&quot;...&quot; 
  
  msg=&quot;vulcand/oxy/roundrobin/rr: Forwarding this request to URL&quot; Request=&quot;...&quot; ForwardURL=&quot;http://127.0.0.1:5000&quot;
  
  msg=&quot;'502 Bad Gateway' caused by: dial tcp 127.0.0.1:5000: connect: connection refused&quot;
  
  msg=&quot;vulcand/oxy/roundrobin/rr: completed ServeHttp on request&quot; Request=&quot;...&quot; 
  </code></pre>
  <p>The request looks like this:</p>
  <pre><code>{
    &quot;Method&quot;: &quot;GET&quot;,
    &quot;URL&quot;: {
      &quot;Scheme&quot;: &quot;&quot;,
      &quot;Opaque&quot;: &quot;&quot;,
      &quot;User&quot;: null,
      &quot;Host&quot;: &quot;&quot;,
      &quot;Path&quot;: &quot;/&quot;,
      &quot;RawPath&quot;: &quot;&quot;,
      &quot;ForceQuery&quot;: false,
      &quot;RawQuery&quot;: &quot;&quot;,
      &quot;Fragment&quot;: &quot;&quot;
    },
    &quot;Proto&quot;: &quot;HTTP/1.1&quot;,
    &quot;ProtoMajor&quot;: 1,
    &quot;ProtoMinor&quot;: 1,
    &quot;Header&quot;: {
      &quot;Accept&quot;: [
        &quot;text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9&quot;
      ],
      &quot;Accept-Encoding&quot;: [
        &quot;gzip, deflate&quot;
      ],
      &quot;Accept-Language&quot;: [
        &quot;en-US,en;q=0.9,da;q=0.8,jv;q=0.7,sv;q=0.6,nb;q=0.5,nl;q=0.4&quot;
      ],
      &quot;Cache-Control&quot;: [
        &quot;max-age=0&quot;
      ],
      &quot;Connection&quot;: [
        &quot;keep-alive&quot;
      ],
      &quot;Upgrade-Insecure-Requests&quot;: [
        &quot;1&quot;
      ],
      &quot;User-Agent&quot;: [
        &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36&quot;
      ],
      &quot;X-Forwarded-Host&quot;: [
        &quot;3d.myWebsite.io&quot;
      ],
      &quot;X-Forwarded-Port&quot;: [
        &quot;80&quot;
      ],
      &quot;X-Forwarded-Proto&quot;: [
        &quot;http&quot;
      ],
      &quot;X-Forwarded-Server&quot;: [
        &quot;db3b41941e8c&quot;
      ],
      &quot;X-Real-Ip&quot;: [
        &quot;192.168.1.1&quot;
      ]
    },
    &quot;ContentLength&quot;: 0,
    &quot;TransferEncoding&quot;: null,
    &quot;Host&quot;: &quot;3d.myWebsite.io&quot;,
    &quot;Form&quot;: null,
    &quot;PostForm&quot;: null,
    &quot;MultipartForm&quot;: null,
    &quot;Trailer&quot;: null,
    &quot;RemoteAddr&quot;: &quot;192.168.1.1:56060&quot;,
    &quot;RequestURI&quot;: &quot;/&quot;,
    &quot;TLS&quot;: null
  }
  </code></pre>
  <p>The <code>/etc/haproxy/haproxy.cfg</code> that allowed this to work now looks as so:</p>
  <pre class="lang-sh prettyprint-override"><code>global
          maxconn 4096
          user haproxy
          group haproxy
          log 127.0.0.1 local1 debug
  
  defaults
          log     global
          mode    http
          option  httplog
          option  dontlognull
          retries 3
          option redispatch
          option http-server-close
          option forwardfor
          maxconn 2000
          timeout connect 5s
          timeout client  15min
          timeout server  15min
  
  #frontend public
  #        bind :::80 v4v6
  #        bind :::443 v4v6 ssl crt /etc/ssl/snakeoil.pem
  #        option forwardfor except 127.0.0.1
  #        use_backend webcam if { path_beg /webcam/ }
  #        default_backend octoprint
  
  #backend octoprint
  #        acl needs_scheme req.hdr_cnt(X-Scheme) eq 0
  
  #        reqrep ^([^\ :]*)\ /(.*) \1\ /\2
  #        reqadd X-Scheme:\ https if needs_scheme { ssl_fc }
  #        reqadd X-Scheme:\ http if needs_scheme !{ ssl_fc }
  #        option forwardfor
  #        server octoprint1 127.0.0.1:5000
  #        errorfile 503 /etc/haproxy/errors/503-no-octoprint.http
  
  #backend webcam
  #        reqrep ^([^\ :]*)\ /webcam/(.*)     \1\ /\2
  #        server webcam1  127.0.0.1:8080
  #        errorfile 503 /etc/haproxy/errors/503-no-webcam.http
  </code></pre>
  <p>What can I do?</p>