# How to Enable Proxy protocol for NGINX Ingress Controller with CLB in EKS #### Common Use Case: *Customer wants to receive the client connection (real IP address) information passed through the load balancer to Pods running in EKS Cluster*. Example Architecture: ``` CLB ---> Node ---> backend App Pod (nginx appserver) ``` ## Pre-requisite * Install latest [aws-cli](https://docs.aws.amazon.com/cli/latest/userguide/installing.html). * An existing AWS EKS Cluster. * Install NGINX ingress controller as [here](https://kubernetes.github.io/ingress-nginx/deploy/#quick-start). --- ## Below are the steps to be followed for enabling proxy in Classic Load Balancer (CLB). 1. Enable proxy protocol support in CLB. Refer to [documentation](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-proxy-protocol.html). ### To enable proxy protocol for your load balancer: Create a policy for the loadbalancer that can be applied to a listener port. ~~~ aws elb create-load-balancer-policy —load-balancer-name my-loadbalancer —policy-name my-ProxyProtocol-policy —policy-type-name ProxyProtocolPolicyType —policy-attributes AttributeName=ProxyProtocol,AttributeValue=true ~~~ Then, Run below command to enable the newly created policy on the specified instance port mapped with listener port 80 and 443. ~~~ aws elb set-load-balancer-policies-for-backend-server —load-balancer-name my-loadbalancer —instance-port —policy-names my-ProxyProtocol-policy ~~~ *Replace `` with the ports mapped to your CLB listeners on port 80 and/or 443* ### Verify that proxy protocol is enabled using below ~~~ aws elb describe-load-balancers —load-balancer-name my-loadbalancer ~~~ Example output: ~~~ "BackendServerDescriptions": [ { “InstancePort”: 32486, “PolicyNames”: [ “my-ProxyProtocol-policy” ] }, { “InstancePort”: 32729, “PolicyNames”: [ “my-ProxyProtocol-policy” ] } ], ~~~ *Note*: Instance port is the randomly generated port mapped with listener 80 and 443. 2. Added below annotation in nginx ingress controller configMap and restart the controller pods. ~~~ kubectl edit cm ingress-nginx-controller -n ingress-nginx ~~~ *Add the parameters below into the data section of the configmap* ``` use-forwarded-headers: "true" compute-full-forwarded-for: "true" use-proxy-protocol: "true" forwarded-for-header: "X-Forwarded-For" ``` 3. Deploy the sample deployment with nginx pod. ``` kubectl create -f nginx-app.yaml ``` 4. Create the service to expose the deployment pod. ``` kubectl create -f nginx-svc.yml ``` 5. Create nginx ingress object using below manifest. ``` kubectl create -f nginx-ingress.yml ``` 6. Tested using load balancer DNS name and can see the result below ~~~ curl http://a47974c475b84429caa06f9fc12635a9-635731211.ap-southeast-1.elb.amazonaws.com/ Welcome to nginx!