1

我正在尝试根据 Traefik 的文档在我的 kubernetes 集群中测试和实现 Traefik 的https重定向功能: https ://docs.traefik.io/middlewares/overview/ 。这是Middlewareand的定义IngressRoute

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: ingressroutetls
  namespace: default
spec:
  entryPoints:
    - web
    - websecure
  routes:
  - match: Host(`your.domain.name`) && Host(`www.your.domain.name`)
    kind: Rule
    services:
    - name: traefik-dashboard
      port: 8080
    middlewares:
      - name: redirectscheme
  tls:
    secretName: cloud-tls
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: redirectscheme
spec:
  redirectScheme:
    scheme: https

但是,https ://your.domain.name 有效,而http://your.domain.name给了我一个404 page not found。有谁知道我配置错了什么?

4

1 回答 1

3

这对我有用:

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: a3-ing
  namespace: default
spec:
  entryPoints:
    - websecure
  routes:
  - match: Host(`example.com`)
    kind: Rule
    services:
    - name: whoami
      port: 80
  tls:
    certResolver: default
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: a3-ing-red
  namespace: default
spec:
  entryPoints:
    - web
  routes:
    - match: Host(`example.com`)
      middlewares:
        - name: test-redirectscheme
      kind: Rule
      services:
        - name: whoami
          port: 80
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: a3-ing-www
  namespace: default
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`www.example.com`)
      kind: Rule
      services:
        - name: whoami
          port: 80
  tls:
    certResolver: default
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: a3-ing-www-red
  namespace: default
spec:
  entryPoints:
    - web
  routes:
    - match: Host(`www.example.com`)
      kind: Rule
      middlewares:
        - name: test-redirectscheme
      services:
        - name: whoami
          port: 80
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: test-redirectscheme
  namespace: default  
spec:
  redirectScheme:
    scheme: https
于 2019-12-18T20:04:32.710 回答