Setting Nginx Header Host without breaking an existing ingress

5/16/2019

When I add proxy_set_header Host $host; to my ingress file, it stops working. I think I need to set that as the value as I'm trying to expose SSL over Keycloak where they state

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.

This is my ingress file:

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

How do I set it up that I can set the host?

-- RAbraham
keycloak
kubernetes
nginx
nginx-ingress

0 Answers