Problem

Client IP address is seen as 10.244.x.x

Reason/Cause

In the Kubernetes NodePort structure, if the X-Forwarded-For value does not come from the client, it forwards the pod's IP address to the back-end application by default. As a solution, we can solve it by setting the externalTrafficPolicy value to Local, but this time, since NodePort does not forward the incoming request to other servers in the Cluster, there is an access problem. It is necessary to know the relevant Node and go to it.

Solution

Since Apinizer Workers will be placed behind a structure such as Nginx or F5, xff information should be added to the header as follows in the configuration file of the relevant loadbalancer.


location /apigateway/ {proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://YOUR-IP:PORT/apigateway/;
} # end location