Rancher K8S - Nginx Load Balance

Hi,

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?

Thanks!

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:

date:
use-proxy-protocol: “true”

The file will look like this:

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

kind: ConfigMap
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{“apiVersion”:“v1”,“data”:null,“kind”:“ConfigMap”,“metadata”:{“annotations”:{},“labels”:{“app”:“ingress-nginx”},“name”:“nginx-configuration”,“namespace”:“ingress-nginx”}}
creationTimestamp: “2020-02-05T17:46:34Z”
labels:
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