Krakend is masking Client IP address

Viewed 313

I have a python program that fetches the client IP using request.client.host headers and Fast API. This program is running on a kubernetes pod(ip-pod). I have another Gateway API implemented using KrakenD and this runs on another pod in kubernetes cluster. The Kubernetes yaml files for both(ip-pod and KrakenD) have the property externalTrafficPolicy: Local I am unable to retrieve the real IP of the user and this could be because KrakenD is not allowing the real IP to reach to the ip-pod. I have tested the program by exposing the ip-pod to the internet using type: LoadBalancer and that way it gives the correct client IP. But when I use the KrakenD gateway, the IP is something different(private IP).

1 Answers

You can use the no-op with krakenD which will forward request to the backend

https://www.krakend.io/docs/endpoints/no-op/

you can check parameter forwarding config in your YAML of KrakenD also

"headers_to_pass":[  
      "*"
]

If you are getting client IP in header KrakenD will forward it to backend.

https://www.krakend.io/docs/endpoints/parameter-forwarding/#sending-all-client-headers-to-the-backends

Refrence

{
              "endpoint": "/api/v1/{uid}/user",
              "method": "GET",
              "headers_to_pass": [ "*" ],
              "querystring_params": [ "*" ],
              "output_encoding": "no-op",
              "concurrent_calls": 1,
              "backend": [
                  {
                      "url_pattern": "/api/{uid}/user",
                      "encoding": "no-op",
                      "host": [
                          "http://IP:Port"
                      ]
                  }
              ]
          }
Related