How to use traefik to proxy a https request to an external server?

I am new to traefik and using v2.0. I am trying to replace one of our custom api gateway with traefik's community version. Our main requirement is to proxy an incoming HTTPS request to another external domain using HTTPS protocol. For example, my incoming request is https://www.abc.com and I want to proxy that request to https://www.xyz.com. I tried with redirect middleware, it works with a redirect. When I send https://www.abc.com request to traefik, it returns 301/302 error with the https://www.xyz.com and the browser redirects the call to https://www.xyz.com. However, in our use case, we don't want the redirect. The request should pass through traefik and It should rewrite the URL. I spend quite some time reading the documentation but have had no luck so far. Is it possible to meet the requirement using traefik and if so, how can I do it?

I found a solution to address this issue. I am putting my steps to help other community members.

The Host header of the request should be the new domain. The most application load balancer uses host-based routing policy. Therefore, the routing to the new location fails if the Host header is not the right one. Here is the configuration for the "Hello world" version of the scenario. Traefik is using the file provider and routing www.abc.com to https://www.yahoo.com

Static Config:

entryPoints:
  http:
    address: :80
  traefik:
    address: :8080
providers:
  providersThrottleDuration: 2s
  file:
    directory: /backend-services/
    watch: true
api:
  insecure: true
log:
  level: DEBUG

Dynamic config file
The file is saved at /backend-services/ location and give the file extension .yml

http:
      middlewares:
        yahoo-Header:
          headers:
            customRequestHeaders:
              Host: "yahoo.com"

      routers:
        yahoo-router:
          entryPoints: ["web"]
          rule: "Host(`abc.com`)"
          service: "yahoo-svc"
          middlewares: 
          - "yahoo-Header"

      services:
        yahoo-svc:
          loadBalancer:
            servers:
            - url: "https://www.yahoo.com"

Nice work Manideep. I'm looking to create an internal traffic splitter that could send traffic through one of two proxies depending on the domain name in the url. You're solution appears to work for yahoo.com (http and https?) do you know if you found a way to wildcard it for all traffic... through traefik :joy:

Thanks and well done :+1:

I'm so happy I found this as I was having this problem as well. But It doesn't appear to work with all sites.
For example I'm trying to do this with a Google Doc which redirects me to signup and Notion document throws an error: "Mismatch between origin and baseUrl (dev)."

I'm assuming this is some sort of protection against a transparent reverse proxy.

Would you be able to make this work for a Google Doc link that has public access enabled?