I have a kubernetes cluster on premise.
I deploy my laravel application and service using nodePort.
idnic@mylaptop:~/$ kubectl get pods -n staging
NAME READY STATUS RESTARTS AGE
mysite-stg-595799c6cd-2nhfn 1/1 Running 0 40m
mysite-stg-595799c6cd-7jz7l 1/1 Running 0 40m
idnic@mylaptop:~/$ kubectl get service -n staging
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
mysite-stg NodePort 10.43.234.209 <none> 80:30111/TCP 41m
and I use the NGINX load balancer by creating an upstream:
upstream my.site {
server 192.168.1.5:30111;
server 192.168.1.4:30111;
server 192.168.1.3:30111 backup;
server 192.168.1.2:30111 backup;
}
server {
server_name my.site;
location / {
proxy_pass http://my.site;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
In my Laravel application, there is a feature to get client IPs accessing my website, but after moving to kubernetes what was detected was the IP address of the Kubernetes worker not the IP address of the client accessing my website.
client IP detect IP kubernetes worker
How do I detect IP clients with my topology above?