Score:0

HTTP_X Forwarded For NGINX Ingress not working

mu flag

I have a simple application running inside AKS. I'm trying to get the IP of the source user when accessing the application. I have created an ingress for the application. When I curl -I https://example-app.xyz I see the source IP in the logs of NGINX ingress controller (It just shows as client IP in the logs). My requirement is to do something like below.

annotations:
    nginx.ingress.kubernetes.io/server-snippet: |
               if ($http_x_forwarded_for != "<my-ip-address>") {
               return 301 https://example-app2.xyz;
                    }

I have added the below to the configmap of NGINX as well.

data:
  use-forwarded-headers: "true"

But all requests are forwarded to https://example-app2.xyz now. I can see the source IP in the logs in NGINX ingress controller. When I curl -I https://example-app.xyz it doesn't even show X-Forwarded- header.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.