Rancher K8S - Nginx Load Balance


We have an environment with k8s + Rancher 2 (3 nodes) and an external nginx that only forwards connections to the k8s cluster according to this documentation: [https://rancher.com/docs/rancher/v2.x/en/installation/k8s-install/]

Load Balancer Tutorial:

The problem is that in the logs of the applications that we host on the rancher, all the source requests only come with the ip address of nginx (load balancer) would need it to come with the real ip address of the person who made the request. Has anyone been through this situation and can help me?


I managed to resolve the situation. On the nginx load balancer I enabled proxy_protocol on both port 80 and port 443.

In rancher I edited the ingress-controller:

kubectl -n ingress-nginx edit cm nginx-configuration
I added the parameter below:

use-proxy-protocol: “true”

The file will look like this:

apiVersion: v1
use-proxy-protocol: “true”

kind: ConfigMap
kubectl.kubernetes.io/last-applied-configuration: |
creationTimestamp: “2020-02-05T17:46:34Z”
app: ingress-nginx
name: nginx-configuration
namespace: ingress-nginx
resourceVersion: “326786484”
selfLink: /api/v1/namespaces/ingress-nginx/configmaps/nginx-configuration
uid: de47b624-8346-4d52-b7cd-d776e7fc4b37