I have a backend service named – backend-service.
The pod of this service does the host based routing, like when run below from the pod –
curl --location 'http://localhost:9900/api/foo'
--header 'Host: foo.example.com'
--header 'Content-Type: application/json'
--data-raw '{
"foo": "bar"
}'
This gives 200 status.
Now I have a ingress rule with host bar.example.com
which has this backend service configured.
when I am accessing bar.example.com
with header ‘Host: foo.example.com’, nginx gives 404 error.
Command used –
curl --location 'http://bar.example.com/api/foo'
--header 'Host: foo.example.com'
--header 'Content-Type: application/json'
--data-raw '{
"foo": "bar"
}'
Below are my ingress annotations –
nginx.ingress.kubernetes.io/affinity: cookie
nginx.ingress.kubernetes.io/session-cookie-expires: "172800"
nginx.ingress.kubernetes.io/session-cookie-max-age: "172800"
nginx.ingress.kubernetes.io/session-cookie-name: SESSION
ingress-nginx-controller configmap –
allow-snippet-annotations: "true"
enable-access-log-for-default-backend: "true"
enable-underscores-in-headers: "true"
large-client-header-buffers: 4 100k
proxy-real-ip-cidr: 10.1.2.3/23,10.1.2.4/24
use-forwarded-headers: "true"
Seems nginx is not preserving the host header passed from client.
What could be issue here ?