title: bitwarden_rs not working behind traefik v2.2 (Bad Gateway)
body: <p>So I'm trying to add bitwarden_rs to my docker network but seems to fail hard.</p>
  <p>I also have a nextcloud docker container running behind traefik (nextcloud.mydomain.com) which is working fine. But adding bitwarden with his own subdomain (bitwarden.mydomain.com) to traefik doesn't want to start working. I'm always getting a Bad Gateway error.</p>
  <h2>Traefik docker-compose</h2>
  <pre><code>version: &quot;3&quot;
  
  services:
    traefik:
      image: traefik:latest
      container_name: traefik
      restart: always
      command:
        - --log.level=DEBUG
        - --api.insecure
        - --api.dashboard
        - --providers.file.directory=/FileProvider/
        - --providers.file.watch=true
        - --providers.docker
        - --providers.docker.exposedbydefault=false
        - --providers.docker.endpoint=unix:///var/run/docker.sock 
        - --entrypoints.web.address=:80
        - --entrypoints.websecure.address=:443
        - --certificatesresolvers.letsencryptresolver.acme.email=my@email.com
        - --certificatesresolvers.letsencryptresolver.acme.storage=./letsencrypt/acme.json
        - --certificatesresolvers.letsencryptresolver.acme.httpchallenge.entrypoint=web
        - --certificatesresolvers.letsencryptresolver.acme.httpchallenge=true
      ports:
        - 80:80
        - 443:443
        - 8080:8080
      volumes:
        - ...
      networks:
        - local-lan
      labels:
        - --traefik.http.middlewares.https.redirectscheme.scheme=https
        - --traefik.http.routers.https_redirect.middlewares=https
        - --traefik.http.routers.https_redirect.rule=(Host(`bitwarden.mydomain.com`) || Host(`nextcloud.mydomain.com`))
        - --traefik.http.routers.https_redirect.entrypoints=web
        - --traefik.docker.network=local-lan
  
  networks:
    local-lan:
        external: true
  </code></pre>
  <h2>traefik dynamic config</h2>
  <pre><code>middlewares:
    ncHeader:
      headers:
        customResponseHeaders:
          stsPreload: true
          stsSeconds: 15552000
    redirect:
      redirectScheme:
        scheme: https
  </code></pre>
  <h2>bitwarden_rs docker-compose</h2>
  <pre><code>version: '3'
  
  services:
    bitwarden:
      image: bitwardenrs/server:latest
      container_name: bitwarden
      restart: always
      volumes:
        - /home/reggi/bitwarden/data:/data
      environment:
        - WEBSOCKET_ENABLED=true
        - WEB_VAULT_ENABLED=true
        - SIGNUPS_ALLOWED=true
        - ADMIN_TOKEN=xxxxxxxxxxx
      ports:
        - 3012:3012
        - 4500:80
      networks:
        - local-lan
      labels:
        - traefik.enable=true
        - traefik.docker.network=local-lan
        - traefik.http.services.bitwarden-ui.loadbalancer.server.port=4500
        - traefik.http.services.bitwarden-ui.loadbalancer.server.scheme=http
  
        - traefik.http.routers.bitwarden-ui-https.rule=Host(`bitwarden.mydomain.com`)
        - traefik.http.routers.bitwarden-ui-https.entrypoints=websecure
        - traefik.http.routers.bitwarden-ui-https.tls=true
        - traefik.http.routers.bitwarden-ui-https.tls.certresolver=letsencryptresolver
        - traefik.http.routers.bitwarden-ui-https.service=bitwarden-ui@docker
  
        - traefik.http.routers.bitwarden-ui-http.rule=Host(`bitwarden.mydomain.com`)
        - traefik.http.routers.bitwarden-ui-http.entrypoints=web
        - traefik.http.routers.bitwarden-ui-http.service=bitwarden-ui@docker
  
        - traefik.http.routers.bitwarden-websocket-https.rule=Host(`bitwarden.mydomain.com`) &amp;&amp; Path(`/notifications/hub`)
        - traefik.http.routers.bitwarden-websocket-https.entrypoints=websecure
        - traefik.http.routers.bitwarden-websocket-https.tls=true
        - traefik.http.routers.bitwarden-websocket-https.tls.certresolver=letsencryptresolver
        - traefik.http.routers.bitwarden-websocket-https.service=bitwarden-websocket
        - traefik.http.routers.bitwarden-websocket-http.rule=Host(`bitwarden.mydomain.com`) &amp;&amp; Path(`/notifications/hub`)
        - traefik.http.routers.bitwarden-websocket-http.entrypoints=web
        - traefik.http.routers.bitwarden-websocket-http.service=bitwarden-websocket
        - traefik.http.services.bitwarden-websocket.loadbalancer.server.port=3012
        
  networks:
   local-lan:
      external: true
  </code></pre>
  <p>Both containers are running fine with this configuration but for some reason, I get a Bad Gateway when I navigate to http(s)://bitwarden.mydomain.com.</p>
  <p>When I navigate to my server IP:4500 bitwarden opens up meaning the docker container is running fine.
  In my traefik log I can find this error:
  <code>time=&quot;2021-03-10T21:06:35Z&quot; level=debug msg=&quot;'502 Bad Gateway' caused by: dial tcp 17.32.0.8:4500: connect: connection refused&quot;</code></p>
  <p>And when I do a simple curl to the bitwarden container from traefik container I get the same error:
  <code>curl --verbose http://17.32.0.8:4500</code>
  <a href="https://i.stack.imgur.com/r40hL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r40hL.png" alt="enter image description here" /></a></p>
  <p>For example, curl to my nextcloud container does work:
  <a href="https://i.stack.imgur.com/nj8i1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nj8i1.png" alt="enter image description here" /></a></p>
  <p>I tried a lot of stuff already but can't seem to figure it out. For nextcloud I could add a trusted proxy domain but that doesn't seem to be possible for bitwarden_rs if I'm not mistaken.</p>
  <ul>
  <li>Adding network label didn't help <a href="https://github.com/traefik/traefik/issues/1254#issuecomment-299114960" rel="nofollow noreferrer">GitHub answer</a></li>
  <li>Using these config labels didn't help as well <a href="https://github.com/dani-garcia/bitwarden_rs/issues/872#issuecomment-590052295" rel="nofollow noreferrer">GitHub answer</a></li>
  </ul>
  <p>Does someone know what I'm missing or doing wrong?</p>