Traefik配置 跟教程一样, 看了其他回答,加了中间件也不行,这个是我的demo,这个demo目前是正常的,http 跟https都能访问,如果在 https 的 ingressroute 加上 中间件,访问失败
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: test02-nginx-ingress
namespace: test
spec:
entryPoints:
- https
routes:
- match: Host(`test02.example.com`) && PathPrefix(`/`)
kind: Rule
services:
- name: test02-traefik-advanced-service
port: 80
tls:
secretName: test-cert
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: traefik-advanced-ingressroute
namespace: test
spec:
entryPoints:
- http
routes:
- match: Host(`test02.example.com`) && PathPrefix(`/`)
kind: Rule
# middlewares:
# - name: redirect-to-https # 选择 中间件
services:
- name: test02-traefik-advanced-service
port: 80
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: redirect-to-https
spec:
redirectScheme:
scheme: https
permanent: false # 永久重定向,如果需要临时重定向,可以将其设置为false
---
apiVersion: v1
kind: Service
metadata:
name: test02-traefik-advanced-service
namespace: test
spec:
type: NodePort
selector:
app: test02-traefik-advanced-pod
ports:
- name: http
port: 80
# nodePort: 30083
---
apiVersion: v1
kind: Pod
metadata:
name: test02-traefik-advanced-pod
namespace: test
labels:
app: test02-traefik-advanced-pod
spec:
containers:
- name: nginx
image: nginx:1.17.1
ports:
- name: nginx-port
containerPort: 80