在不破坏现有入口的情况下设置Nginx Header Host

时间:2019-05-16 22:05:47

标签: nginx kubernetes keycloak nginx-ingress

当我将proxy_set_header Host $host;添加到我的入口文件时,它将停止工作。我想在尝试通过其声明的Keycloak公开SSL时将其设置为值

Configure your reverse proxy or loadbalancer to properly 
set X-Forwarded-For and X-Forwarded-Proto HTTP headers.

Configure your reverse proxy or loadbalancer to preserve
the original 'Host' HTTP header.

这是我的入口文件:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-keycloak
  annotations:
    nginx.ingress.kubernetes.io/configuration-snippet: |
      proxy_set_header        Host $host;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        X-Forwarded-Proto $scheme;

    kubernetes.io/ingress.class: "nginx"
    certmanager.k8s.io/issuer: "letsencrypt-prod"
    certmanager.k8s.io/acme-challenge-type: http01


spec:
  tls:
  - hosts:
    - mysite.com
    secretName: staging-iam-tls
  rules:
  - host: mysite.com
    http:
      paths:
      - path: /auth
        backend:
          serviceName: keycloak-http
          servicePort: 80

如何设置主机设置?

0 个答案:

没有答案