Yash patel
Yash patel

Reputation: 23

Match k8s ingress host rule with Host header of incoming request

I have nginx load balancer which takes public facing requests and then depending upon its config, it forwards those requests to my cluster. Then ingress matches host and path for requests and it forward these further to internal service of cluster.

Nginx Load balancer -> Ingress -> internal services of cluster

Here I am forwarding request to Ingress from NGINX load balancer with proxy_pass and also setting Host header to $host using proxy_set_header.

Now, the issue is that ingress is not matching the host header, which is passed from NGINX load balancer. Is there a way to match ingres host rule to host header passed from NGINX?

Upvotes: 0

Views: 159

Answers (1)

Fariya Rahmat
Fariya Rahmat

Reputation: 3220

To match ingress host rule to host header passed from NGINX you can consider using annotation. Also make sure your NGINX configuration should correctly set the host header.

You can add Kubernetes annotations to specific Ingress objects to customize their behavior.

Annotation looks like this :

nginx.ingress.kubernetes.io/configuration-snippet: |
  more_set_headers "Request-Id: $req_id";

The Ingress resource can use basic NGINX features such as host or path-based routing and TLS termination. Advanced features like rewriting the request URI or inserting additional response headers can be enabled with Annotations.

Upvotes: 0

Related Questions