kubernetes / ingress-nginx

Ingress NGINX Controller for Kubernetes
https://kubernetes.github.io/ingress-nginx/
Apache License 2.0
17.53k stars 8.26k forks source link

proxy_set_header Host set to $http_host (not $host) #10582

Closed gotsysdba closed 1 month ago

gotsysdba commented 1 year ago

What happened:

Vanilla deployment... an application was redirecting to http://<ip>:443 (proto/port mismatch). It was determined that the <ip>:<port> was coming from the Host header which was being set by:

set $best_http_host      $http_host;
proxy_set_header Host    $best_http_host;

To resolve, the annotation nginx.ingress.kubernetes.io/upstream-vhost was used:

nginx.ingress.kubernetes.io/upstream-vhost: $host

The doco's state the annotation "... is useful if you need to call the upstream server by something other than $host".

What you expected to happen:

Based on the annotation doco, proxy_set_header Host should be set to $host when it is actually set to $best_http_host -> $http_host.

Either the default setting is wrong or the doco is??

NGINX Ingress controller version

-------------------------------------------------------------------------------
NGINX Ingress controller
  Release:       v1.8.1
  Build:         dc88dce9ea5e700f3301d16f971fa17c6cfe757d
  Repository:    https://github.com/kubernetes/ingress-nginx
  nginx version: nginx/1.21.6

-------------------------------------------------------------------------------

Kubernetes version

Server Version: v1.27.2

How was the ingress-nginx-controller installed:

Helm: repo: https://kubernetes.github.io/ingress-nginx version: 4.7.1

How to reproduce this issue:

Deploy using Helm, then run:

POD_NAMESPACE=ingress-nginx
POD_NAME=$(kubectl get pods -n $POD_NAMESPACE -l app.kubernetes.io/name=ingress-nginx --field-selector=status.phase=Running -o jsonpath='{.items[0].metadata.name}')

kubectl exec -it $POD_NAME -n $POD_NAMESPACE -- cat /etc/nginx/nginx.conf |grep 'proxy_set_header Host'
kubectl exec -it $POD_NAME -n $POD_NAMESPACE -- cat /etc/nginx/nginx.conf |grep 'set $best_http_host'
k8s-ci-robot commented 1 year ago

This issue is currently awaiting triage.

If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
longwuyuan commented 1 year ago

@gotsysdba the issue description seems to be too succint or too short.

A new issue template asks questions that help readers get information that is actionable. Please check the new issue template and answer the questions that are asked there so that the issue descriptions becomes elaborate enough to help readers take some action.

/remove-kind bug

github-actions[bot] commented 11 months ago

This is stale, but we won't close it automatically, just bare in mind the maintainers may be busy with other tasks and will reach your issue ASAP. If you have any question or request to prioritize this, please reach #ingress-nginx-dev on Kubernetes Slack.

longwuyuan commented 1 month ago

Its been a year since any activity here and the issue description is too short to think up a action item. So I am closing this. /close

k8s-ci-robot commented 1 month ago

@longwuyuan: Closing this issue.

In response to [this](https://github.com/kubernetes/ingress-nginx/issues/10582#issuecomment-2356060736): >Its been a year since any activity here and the issue description is too short to think up a action item. So I am closing this. >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.