I ran into this problem on a kubernets,
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.
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: test-redirectregex
spec:
redirectRegex:
regex: ^http://localhost/(.*)
replacement: https://mydomain/${1}
I don't know if this is my own configuration problem or a bug.
