# I want to redirect https to https

**URL:** <https://community.traefik.io/t/i-want-to-redirect-https-to-https/20738>\
**Category:** Traefik v2\
**Tags:** file\
**Created:** [December 11, 2023, 10:43am UTC](https://community.traefik.io/t/i-want-to-redirect-https-to-https/20738 "2023-12-11T10:43:58Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![adeelhashmi145](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/adeelhashmi145/32/7945_2.png) [@adeelhashmi145](https://community.traefik.io/u/adeelhashmi145)\
**Post date:** [December 11, 2023, 10:43am UTC](https://community.traefik.io/t/i-want-to-redirect-https-to-https/20738/1 "2023-12-11T10:43:58Z")

</div>

I have one server on which a domain abc com is hosted with nginx. The ssl certbot is also applied via nginx.

I have lxc container on that same machine in which a traefik is running.

I want to redirect traefik from xyz com to abc com. If i type in browser abc com it should give me xyz com

This is my static and dynamic configs.

```auto
## Static configuration
entryPoints:
  http:
    address: ":80"

  https:
    address: ":443"

certificatesResolvers:
  myresolver:
    acme:
        email: shell@gmail.com
        storage: acme.json
        httpChallenge:
          entryPoint: http

api:
  dashboard: true # On port 8080
  insecure: true

providers:
  file:
# filename: /etc/traefik/dynamic.yml
# filename: /etc/traefik/tls.yml
    filename: /etc/traefik/redir.yml
    watch: true

log:
# filePath: "/var/log/traefik/trafik.log"
  level: DEBUG
accessLog: {}

```

```auto
http:
  routers:
    to-runpod:
      rule: "Host(`abc.com`)"
      entryPoints:
        - https
# middlewares:
# - redir
# - cors
      service: runpodserv
      tls:
        certResolver: myresolver

  services:
    runpodserv:
      loadBalancer:
        servers:
          - url: "https://xyz.com"
        passHostHeader: true

```

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [December 11, 2023, 10:50am UTC](https://community.traefik.io/t/i-want-to-redirect-https-to-https/20738/2 "2023-12-11T10:50:31Z")

</div>

Should Traefik show you the other site (proxy content) or really redirect (tell the browser to load another domain)?

---

<div class="post-metadata">

**Author:** ![adeelhashmi145](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/adeelhashmi145/32/7945_2.png) [@adeelhashmi145](https://community.traefik.io/u/adeelhashmi145)\
**Post date:** [December 11, 2023, 10:56am UTC](https://community.traefik.io/t/i-want-to-redirect-https-to-https/20738/3 "2023-12-11T10:56:54Z")

</div>

Like i type [abc.com](http://abc.com) and The content should get changed to [xyz.com](http://xyz.com) in browser not the url. Idk what is the best term for it.

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [December 11, 2023, 11:32am UTC](https://community.traefik.io/t/i-want-to-redirect-https-to-https/20738/4 "2023-12-11T11:32:01Z")

</div>

Then that’s what your current config should do. Is it not working? What’s the error?

Note that many websites have precautions that this is not possible, with CORS headers and JS.

---

<div class="post-metadata">

**Author:** ![adeelhashmi145](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/adeelhashmi145/32/7945_2.png) [@adeelhashmi145](https://community.traefik.io/u/adeelhashmi145)\
**Post date:** [December 11, 2023, 11:35am UTC](https://community.traefik.io/t/i-want-to-redirect-https-to-https/20738/5 "2023-12-11T11:35:56Z")

</div>

I get this in logs

- 
  - [11/Dec/2023:11:32:45 +0000] "GET / HTTP/1.0" 404 19 "-" "-" 4 "-" "-" 0ms  
If i remove the tls and entrypoint-https in dynamic configuratiton it will use the service but that would 403 forbidden.  
I wonder why its not using service like this with tls and entrpooint  
x.69.105.1 - - [11/Dec/2023:10:14:18 +0000] "GET / HTTP/1.0" 403 553 "-" "-" 1 "to-runpod@file" "xyz com" 60ms

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [December 11, 2023, 11:57am UTC](https://community.traefik.io/t/i-want-to-redirect-https-to-https/20738/6 "2023-12-11T11:57:14Z")

</div>

Do you use the correct filename in `provider.file` to match your dynamic config file?

---

<div class="post-metadata">

**Author:** ![adeelhashmi145](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/adeelhashmi145/32/7945_2.png) [@adeelhashmi145](https://community.traefik.io/u/adeelhashmi145)\
**Post date:** [December 11, 2023, 12:10pm UTC](https://community.traefik.io/t/i-want-to-redirect-https-to-https/20738/7 "2023-12-11T12:10:14Z")

</div>

Yes it shows in logs that it loaded.  
DEBU[2023-12-11T11:54:21Z] \*file.Provider provider configuration: {"watch":true,"filename":"/etc/traefik/redir.yml"}  
INFO[2023-12-11T11:54:21Z] Starting provider \*traefik.Provider

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [December 11, 2023, 12:38pm UTC](https://community.traefik.io/t/i-want-to-redirect-https-to-https/20738/8 "2023-12-11T12:38:02Z")

</div>

Try to set `passHostHeader: false`, otherwise Host header `abc.com` will be sent to `xyz.com`.

---

<div class="post-metadata">

**Author:** ![adeelhashmi145](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/adeelhashmi145/32/7945_2.png) [@adeelhashmi145](https://community.traefik.io/u/adeelhashmi145)\
**Post date:** [December 12, 2023, 4:39am UTC](https://community.traefik.io/t/i-want-to-redirect-https-to-https/20738/9 "2023-12-12T04:39:04Z")

</div>

I set it false, but still same behaviour, i am really confused, whats going on.

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [December 12, 2023, 6:40am UTC](https://community.traefik.io/t/i-want-to-redirect-https-to-https/20738/10 "2023-12-12T06:40:37Z")

</div>

Enable and check Traefik access log in JSON format.

---

<div class="post-metadata">

**Author:** ![adeelhashmi145](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/adeelhashmi145/32/7945_2.png) [@adeelhashmi145](https://community.traefik.io/u/adeelhashmi145)\
**Post date:** [December 12, 2023, 7:00am UTC](https://community.traefik.io/t/i-want-to-redirect-https-to-https/20738/11 "2023-12-12T07:00:48Z")

</div>

This below configs works good, although the basic auth don't work as intended. Working on it

```auto
http:
  routers:
    to-runpod:
      rule: "Host(`abc.com`) && Path(`/v1/chat/completions`)"
      middlewares:
        - redir
      service: runpodserv
    dashboard:
      rule: "Host(`abc.com`) && PathPrefix(`/dashboard`)"
      service: api@internal
      middlewares:
        - dashboard-auth

  services:
    runpodserv:
      loadBalancer:
        servers:
          - url: "https://xyz.com"
        passHostHeader: false

  middlewares:
    redir:
      redirectRegex:
         regex: "^https://abc.com/(.*)"
         replacement: "xyz.com/${1}"
         permanent: true

    dashboard-auth:
        basicAuth:
          users:
            - "admin:$Kanger"

```

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [December 12, 2023, 7:47am UTC](https://community.traefik.io/t/i-want-to-redirect-https-to-https/20738/12 "2023-12-12T07:47:56Z")

</div>

`basicAuth` uses a hashed password, not plain.

---

<div class="post-metadata">

**Author:** ![adeelhashmi145](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/adeelhashmi145/32/7945_2.png) [@adeelhashmi145](https://community.traefik.io/u/adeelhashmi145)\
**Post date:** [December 12, 2023, 8:32am UTC](https://community.traefik.io/t/i-want-to-redirect-https-to-https/20738/13 "2023-12-12T08:32:18Z")

</div>

Yes ofc, thats not the reason actually i want to access my dashboard at abc com /dashboard, i can access the dashboard but it don't get any values.

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [December 12, 2023, 3:46pm UTC](https://community.traefik.io/t/i-want-to-redirect-https-to-https/20738/14 "2023-12-12T15:46:16Z")

</div>

Check the [doc](https://doc.traefik.io/traefik/operations/dashboard/#dashboard-router-rule), you need `/api`, too.

```auto
# Dynamic Configuration
labels:
  - "traefik.http.routers.dashboard.rule=Host(`traefik.example.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
  - "traefik.http.routers.dashboard.service=api@internal"
  - "traefik.http.routers.dashboard.middlewares=auth"
  - "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0"

```

When you do setup your own routing for dashboard, you probably should not use `insecure`:

```auto
api:
  dashboard: true # On port 8080
  insecure: true

```
