Configuring any HTTP port with Let'sencrypt certificates

There are a few solutions on Internet related to the problem I am facing, But I couldn't follow them as they have different environment or setup and I am newbie to take solutions from them and incorporate within my environment.
So, I am working on a problem of forwarding the incoming requests from the internet to the services running on my server. For example, I have a server serving a webpage on and many other like this. Using Traefik reverse proxy, I forwarded the requests coming from internet on my domain - (for example).
And this setup works fine. Below are the files that I have used:

version: '3'


    restart: always
    image: traefik:v2.9
    - "443:443"
    - "80:80"
    - ./traefik.toml:/etc/traefik/traefik.toml
    - /var/run/docker.sock:/var/run/docker.sock
    - ./services.toml:/etc/traefik/services.toml
    - ./acme.json:/acme.json

    - "traefik.http.routers.api.rule=Host(``)" 
    - "traefik.http.routers.api.service=api@internal"
    - "traefik.http.routers.api.entrypoints=http"
    - "traefik.http.routers.api.middlewares=auth"
    - "traefik.http.middlewares.auth.basicauth.users=user:$$;;;$$;;;;;"

    - "traefik.http.routers.nas.entrypoints=http,https"
    - "traefik.http.routers.nas.rule=Host(``)"
    - "traefik.http.routers.nas.service=nas@file"
    - "traefik.http.routers.nas.tls=true"
    - "traefik.http.routers.nas.tls.certresolver=wilson"


          url = ""


  address = ":80"
  address = ":443"


  endpoint = "unix:///var/run/docker.sock"

  filename = "/etc/traefik/services.toml"

  email = ""
  storage = "acme.json"
    entryPoint = "http"

The above are the files that I have used. The localhost is serving a single webpage using python server on port 5000.

I am able to access this locally hosted webpage on But I want to deploy it on HTTPs with Let'sencrypt certificate. I have tried many things but couldn't succeed as I am new using Traefik.

I would be helpful if someone could help in deploying the forwarded domain name on HTTPs on port 5000 or forwarding the localhost:5000 to

LetsEncrypt needs domain validation. For httpChallenge you need port 80, for tlsChallenge you need port 443. Only dnsChallenge enables other ports, but it’s usually a bit more complicated to set up.

You want to forward to, but that will probably not work. Localhost within a Docker container like Traefik is not the localhost of the server, on which your target service might be listening.

Thanks for your answer @bluepuma77.
But The service running is on localhost on my server directly.

Traefik is running in a Docker container, then I would not expect this to work: