2

我的问题是我的 kubernetes 集群中的 traefik 入口控制器确实响应404 page not foundhttp但是我从服务中https得到了真正的响应。

这发生在我将 TLS 部分添加到IngressRoute.

这是我的 IngressRoute:

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: example-backend
  namespace: example
spec:
  entryPoints:
    - web
    - websecure
  routes:
  - match: Host(`api.example.com`)
    kind: Rule
    priority: 10
    services:
    - name: example-backend-service
      port: 80
  tls:
    secretName: tls-secret # I'm using my own certificate, not Let's Encrypt

为什么我没有得到真实/相同的响应https

4

1 回答 1

3

由于 TLS 适用于路由器,因此您不能只有一个 IngressRoute 来处理这两种情况。

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: example-backend
  namespace: example
spec:
  entryPoints:
    - websecure
  routes:
  - match: Host(`api.example.com`)
    kind: Rule
    priority: 10
    services:
    - name: example-backend-service
      port: 80
  tls:
    secretName: tls-secret

---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: example-backend-redirect
  namespace: example
spec:
  entryPoints:
    - web
  routes:
  - match: Host(`api.example.com`)
    kind: Rule
    priority: 10
    services:
    # in this IngressRoute the service will be never called
    # because of the redirect middleware.
    - name: example-backend-service
      port: 80
    middlewares:
    - name: https_redirect

---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: https_redirect
spec:
  redirectScheme:
    scheme: https
    permanent: true
于 2020-02-05T11:35:19.743 回答