X-Forwarded-Port is always fixed to 443.

Author: jclab-josephCreated Mar 19, 2024Updated Jan 29, 2026
Labelstriage/needs-informationneeds-kindneeds-triageneeds-priority

What happened:

X-Forwarded-Port is always fixed to 443. Even if change --https-port, it is always fixed to 443.

Because of this, we got the following results:

GET /hello HTTP/1.1
Host: 172.17.0.4:5440
X-Request-ID: fa76d3f6f9e040a4e4efef1f78bc388a
X-Real-IP: 172.16.1.81
X-Forwarded-For: 172.16.1.81
X-Forwarded-Host: 172.17.0.4:5440
X-Forwarded-Port: 443
X-Forwarded-Proto: https
X-Forwarded-Scheme: https
X-Scheme: https
Origin: https://172.17.0.4:5440
...

In spring-boot, 403 is caused if the origin port and X-Forwarded-Port are different.

What you expected to happen:

It should be changed to https listen port.

NGINX Ingress controller version (exec into the pod and run nginx-ingress-controller --version.):

NGINX Ingress controller
  Release:       1.10.0
  Build:         71f78d4
  Repository:    https://github.com/kubernetes/ingress-nginx
  nginx version: nginx/1.25.3

Kubernetes version (use kubectl version): v1.27.11+rke2r1

How to reproduce this issue:

helm install nginx-ingress bitnami/nginx-ingress-controller -f values.yaml

values.yaml:

ingressClassResource:
  name: test
  controllerClass: "k8s.io/ingress-nginx-test"
electionID: test-ingress-controller-leader
kind: DaemonSet
daemonset:
  useHostPort: true
  hostPorts:
    http: 5000
    https: 5443
containerPorts:
  http: 5000
  https: 5443
extraArgs:
  http-port: "5000"
  https-port: "5443"

Source: kubernetes/ingress-nginx