** X-Forwarded-For being overwritten or appended by request sent with http headers parameters ** #3405
Replies: 3 comments 2 replies
-
We are experiencing the exact same issue. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Hi there, Thanks for the detailed report and for your interest in the project! It looks to me like you are migrating from the community Ingress NGINX (kubernetes/ingress-nginx) project to NGINX Gateway Fabric. What you are seeing here is a behavioral difference between the community Ingress NGINX project, and both the NGINX Ingress Controller (nginx/kubernetes-ingress) and the NGINX Gateway Fabric projects. Ingress NGINX's default behavior is NGF and NIC use This difference is worth keeping in mind when migrating between projects. For your immediate security concern, consider using X-Real-IP for IP whitelisting since it provides consistent behavior regardless of which ingress solution you're using:
(As a side note, many security teams are moving away from header-based IP whitelisting toward more robust authentication methods, but that's beyond the scope of this discussion.) Update: What might actually help you for this use case is the RewriteClientIP setting in NGINXProxy. |
Beta Was this translation helpful? Give feedback.
-
Hi, Thanks for replying and making it clear why this is expected behaviour.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone recently we migrated from nginx ingress controller to nginx-gateway-fabric for some of services and one of weird issue or miss configuration we are facing i would really appreciate any help if there is any solution to avoid this or any suggestions.
ISSUE:
We are handling ip whitelisting at application level for our third party's different ips, but it started failing because we were not able to get x-forwared-for in http headers we are receiving these many headers
curl --location "*****"
Headers:
host: ******
x-real-ip: ******
x-forwarded-proto: http
x-forwarded-host: ******
x-forwarded-port: 80
connection: close
user-agent: curl/8.4.0
accept: /
now to check exact headers of http packet being passed by http-nginx-fabric-gateway we went through documentations and find out service kubectl apply -f https://raw.githubusercontent.com/nginx/nginx-gateway-fabric/v1.6.2/examples/http-request-header-filter/headers.yaml
we deployed it and check what are headers being printed here they are
Headers:
header 'Host' is ''
header 'X-Forwarded-For' is ''
header 'X-Real-IP' is ''
header 'X-Forwarded-Proto' is 'http'
header 'X-Forwarded-Host' is ''
header 'X-Forwarded-Port' is '80'
header 'Connection' is 'close'
header 'sec-ch-ua' is '"Chromium";v="136", "Google Chrome";v="136", "Not.A/Brand";v="99"'
header 'sec-ch-ua-mobile' is '?0'
header 'sec-ch-ua-platform' is '"macOS"'
header 'Upgrade-Insecure-Requests' is '1'
header 'Accept' is 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7'
header 'Sec-Fetch-Site' is 'none'
header 'Sec-Fetch-Mode' is 'navigate'
header 'Sec-Fetch-User' is '?1'
header 'Sec-Fetch-Dest' is 'document'
header 'Accept-Encoding' is 'gzip, deflate, br, zstd'
header 'Accept-Language' is 'en-GB,en-US;q=0.9,en;q=0.8'
so these is first problem we face and not able to understand how is it not able to get this headers in all services
Major Concern:
Now in order to debug we tried passing custom header to curl request and we find out nginx-fabric-gateway is appending these custom ips, when we were using nginx-ingress-controller it was not possible to change this x-forwared-for ip as any whitelisted ips can be added now it becomes security issue while using http-nginx-fabric-gateway we tried using nginxproxy in order to resolve this but its also appending ip and in cidr range we can not specify as there are multiple ips which i dont want to whitelist at nginx level. In sort i am looking for a way which either help in stopping this appending ip issue or something that tells nginx to not touch any header pass it as it is....
EX:
curl --location '' \
--header 'x-forwarded-for: spoofing'
--header 'x-real-ip: spoofing'
Headers:
header 'Host' is ''
header 'X-Forwarded-For' is 'spoofing , '
header 'X-Real-IP' is ''
header 'X-Forwarded-Proto' is 'http'
header 'X-Forwarded-Host' is '**'
header 'X-Forwarded-Port' is '80'
header 'Connection' is 'close'
header 'User-Agent' is 'curl/8.4.0'
header 'Accept' is '/'
here is nginx file i got by going inside nignx-ingress vs nginx-fabric-gateway
nignx-ingress:
nginx-fabric-gateway
Beta Was this translation helpful? Give feedback.
All reactions