# A global http -\> https redirection?

**URL:** <https://community.traefik.io/t/a-global-http-https-redirection/864>\
**Category:** Traefik v2\
**Created:** [July 11, 2019, 4:34pm UTC](https://community.traefik.io/t/a-global-http-https-redirection/864 "2019-07-11T16:34:05Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![peiwenjian](https://avatars.discourse-cdn.com/v4/letter/p/fbc32d/32.png) [@peiwenjian](https://community.traefik.io/u/peiwenjian)\
**Post date:** [September 23, 2019, 6:06am UTC](https://community.traefik.io/t/a-global-http-https-redirection/864/8 "2019-09-23T06:06:05Z")

</div>

I ran into this problem on a kubernets,

```auto
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: admin
spec:
  entryPoints:
    - web
    - websecure
  routes:
  - match: Host(`pwjtest.zhixueyun.com`) && PathPrefix(`/`)
    kind: Rule
    services:
    - name: traefik
      port: 18080
    # scheme: https
    middlewares:
    - name: admin-https
    - name: admin-auth
    #- name: admin-header
  tls:
    secretName: supersecret
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: admin-https
spec:
  redirectScheme:
    scheme: https
    permanent: true
    port: 443
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: admin-auth
spec:
  basicAuth:
    secret: authsecret

```

访问http://domain 会出现404,并不会重定向http://domain.访问http://domain是正常的.

With two routers, write HTTP as one router and HTTPS as one router, and successfully redirect HTTPS with the following configuration.

```auto
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: test-redirectregex
spec:
  redirectRegex:
    regex: ^http://localhost/(.*)
    replacement: https://mydomain/${1}

```

 ![image](https://us1.discourse-cdn.com/flex020/uploads/containo/original/1X/bf1d0703fdc1d22b29f4f0dd3845a4fc1fea043b.png)  
I don't know if this is my own configuration problem or a bug.

---

_[View the full topic](https://community.traefik.io/t/a-global-http-https-redirection/864)._
