Preserving Client IP in Nginx Ingress Controller with AWS NLB

Infrastructure Developer
Search for a command to run...

Infrastructure Developer
No comments yet. Be the first to comment.
AWS Managed NAT Gateway is a widely-used service that provides seamless internet access for resources within a private VPC subnet. However, its cost structure has been a pain point for many AWS users, with high fees for both hourly usage and data pro...
Configure NTP in timesyncd.conf echo "NTP=169.254.169.123" | sudo tee -a /etc/systemd/timesyncd.conf cat /etc/systemd/timesyncd.conf Enable the timesyncd.service sudo systemctl unmask systemd-timesyncd.service sudo apt install systemd-timesyncd ...

Error waiting to create Instance: Error waiting for Creating Instance: Error code 7, message: Required 'compute.subnetworks.use' permission for

automating time tracking for a more accurate record of time spent on projects

Add the following annotation to your NLB Target Group to enable the Proxy Protocol:
service.beta.kubernetes.io/aws-load-balancer-proxy-protocol: "*"
This ensures that the NLB forwards the original client's IP address along with other connection information.
Modify the values.yaml file of the Nginx Ingress Controller with the following settings:
use-forwarded-headers: "true": This instructs Nginx to use the X-Forwarded-* headers, which may contain the client's original IP address as forwarded by the NLB.
use-proxy-protocol: true: Configures the Nginx Ingress Controller to expect and handle the Proxy Protocol header, including the original client IP, from the NLB.
enable-real-ip: true: Activates the real_ip module in Nginx, allowing it to replace the client IP address (which would appear as the NLB's IP) with the one specified in the X-Forwarded-For or X-Real-IP headers.