添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
1.1.3 Blog Knowledge Base

Troubleshooting: Use Traefik 2.x as ingress controller

| April 20, 2021

Applicable versions

All Longhorn versions with Traefik 2.x as ingress controller.

Note that, the CORS problem would not happen with Traefik 1.x as ingress controller.

Symptoms

The Longhorn GUI frontend API requests sometimes failed to reach longhorn-manager backend.

Reason

The API requests would change the protocol between HTTPS/WSS, and the change would lead to a CORS problem.

Solution

The Traefik 2.x ingress controller does not set the WebSocket headers.

  1. Adds the following middleware to the route for the Longhorn frontend service.

    apiVersion: traefik.containo.us/v1alpha1
    kind: Middleware
    metadata:
      name: svc-longhorn-headers
      namespace: longhorn-system
    spec:
      headers:
        customRequestHeaders:
          X-Forwarded-Proto: "https"
    
  2. Updates the ingress to use the middleware rule.

    apiVersion: networking.k8s.io/v1beta1
    kind: Ingress
    metadata:
      name: longhorn-ingress
      namespace: longhorn-system
      annotations:
        traefik.ingress.kubernetes.io/router.entrypoints: websecure
        traefik.ingress.kubernetes.io/router.tls: "true"       
        traefik.ingress.kubernetes.io/router.middlewares: longhorn-system-svc-longhorn-headers@kubernetescrd
    spec:
      rules:
      - http:
          paths:
          - path: /