title: Traefik port forwarding with docker and ssl apps
body: <p>I'm considering using traefik as a reverse proxy for 2 main purposes :</p>
  <ul>
  <li>Avoid port in URL</li>
  <li>Having multiple hosts for the same container</li>
  </ul>
  <p>Simplified context : I actually have an https app containing a node server (could be dotnet app) and listening on https://domain:port. There is an enpoint that print &quot;ok&quot; if the server is reached.
  I set up traefik to be able to access &quot;https:domain&quot; and be forwarded on the right container.</p>
  <p><strong>docker-compose</strong></p>
  <pre><code>version: '2.2'
    services:
      reverse:
        image: traefik:v2.5
        hostname: traefik.domain
        ports:
          - 80:80
          - 443:443
        volumes:
          - /var/run/docker.sock:/var/run/docker.sock:ro
          - ./configuration/:/configuration/
          - ./certs/:/tools/certs/:ro
        command:
          - --log.level=debug
          - --api.dashboard=true
          - --pilot.dashboard=false
  
          - --providers.docker.exposedbydefault=false
          - --providers.file.directory=/configuration/
          - --providers.file.watch=true
     
          - --entrypoints.web.address=:80
          - --entrypoints.web.http.redirections.entryPoint.to=websecure
          - --entrypoints.web.http.redirections.entrypoint.scheme=https
          - --entrypoints.web.http.redirections.entrypoint.permanent=true
  
          - --entrypoints.websecure.address=:443
          - --entrypoints.websecure.http.tls=true
          - --entrypoints.websecure.forwardedHeaders.insecure=true
        labels:
          traefik.enable: 'true'
  
          # Dashboard
          traefik.http.routers.traefik.rule: Host(`traefik.domain`)
          traefik.http.routers.traefik.service: api@internal
          traefik.http.routers.traefik.entrypoints: websecure
  
      myservice:
        image: myserver/myimage
        hostname: myhostname
        environment:
          - ...
        volumes:
          - ...   
        labels:
          traefik.enable: true
          traefik.http.routers.myservice.rule: Host(`myhostname`)
          traefik.http.routers.myservice.tls: true
          traefik.http.services.myservice.loadbalancer.server.port: 443
         # traefik.http.routers.myservice.entrypoints: websecure &lt;= Tried this.
  
         # Also try this following configuration =&gt;
         # traefik.http.routers.myservice.middlewares: myserviceredirect
         # traefik.http.middlewares.myserviceredirect.redirectscheme.scheme: https
         # traefik.http.middlewares.myserviceredirect.redirectscheme.permanent: true
         # traefik.http.services.myservice.loadbalancer.passHostHeader: true
  </code></pre>
  <p>When I try to reach the following endpoint : https://myhostname/check, I have a gateway timeout.
  When I check logs on the reverse proxy, I see that the forward URL is &quot;http&quot; instead of &quot;https&quot;.</p>
  <blockquote>
  <p>time=&quot;2021-10-29T12:33:11Z&quot; level=debug msg=&quot;vulcand/oxy/roundrobin/rr: Forwarding this request to URL&quot; ForwardURL=&quot;http://XXX.XX.XX.XXX:443&quot; Request=&quot;{&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;/check&quot;,&quot;RawPath&quot;:&quot;&quot;,&quot;ForceQuery&quot;:false,&quot;RawQuery&quot;:&quot;&quot;,&quot;Fragment&quot;:&quot;&quot;,&quot;RawFragment&quot;:&quot;&quot;},&quot;Proto&quot;:&quot;HTTP/2.0&quot;,&quot;ProtoMajor&quot;:2,&quot;ProtoMinor&quot;:0,&quot;Header&quot;:{&quot;Accept&quot;:[&quot;text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,<em>/</em>;q=0.8,application/signed-exchange;v=b3;q=0.9&quot;],&quot;Accept-Encoding&quot;:[&quot;gzip, deflate, br&quot;],&quot;Accept-Language&quot;:[&quot;fr-FR,fr;q=0.9&quot;],&quot;Sec-Ch-Ua&quot;:[&quot;\&quot;Google Chrome\&quot;;v=\&quot;95\&quot;, \&quot;Chromium\&quot;;v=\&quot;95\&quot;, \&quot;;Not A Brand\&quot;;v=\&quot;99\&quot;&quot;],&quot;Sec-Ch-Ua-Mobile&quot;:[&quot;?0&quot;],&quot;Sec-Ch-Ua-Platform&quot;:[&quot;\&quot;Windows\&quot;&quot;],&quot;Sec-Fetch-Dest&quot;:[&quot;document&quot;],&quot;Sec-Fetch-Mode&quot;:[&quot;navigate&quot;],&quot;Sec-Fetch-Site&quot;:[&quot;none&quot;],&quot;Sec-Fetch-User&quot;:[&quot;?1&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/95.0.4638.54 Safari/537.36&quot;],&quot;X-Forwarded-Host&quot;:[&quot;myhostname&quot;],&quot;X-Forwarded-Port&quot;:[&quot;443&quot;],&quot;X-Forwarded-Proto&quot;:[&quot;https&quot;],&quot;X-Forwarded-Server&quot;:[&quot;traefik.domain&quot;],&quot;X-Real-Ip&quot;:[&quot;XXX.XX.XXX.X&quot;]},&quot;ContentLength&quot;:0,&quot;TransferEncoding&quot;:null,&quot;Host&quot;:&quot;myhostname&quot;,&quot;Form&quot;:null,&quot;PostForm&quot;:null,&quot;MultipartForm&quot;:null,&quot;Trailer&quot;:null,&quot;RemoteAddr&quot;:&quot;XXX.XX.XXX.X:62259&quot;,&quot;RequestURI&quot;:&quot;/check&quot;,&quot;TLS&quot;:null}&quot;</p>
  </blockquote>
  <p>What am I missing?</p>
  <p>Note : If I set the node server listening http://myhostname:80 and set port 80 for the loadbalancer, the forware url is ok and I can reach the endpoint.
  I really need the forward url scheme to be https and not http.</p>
  <p>Thanks in advance.</p>