nginx obtains the user's real IP after AWS TCP Classic load balancer

Reference materials https://aws.amazon.com/cn/premiumsupport/knowledge-center/elb-capture-client-ip-addresses/

AWS load balancing needs to be configured to view the original IP

1 Configuration value load balancer proxy

aws elb create-load-balancer-policy --load-balancer-name exxx --policy-name realIPProxyProtocol --policy-type-name ProxyProtocolPolicyType --policy-attributes AttributeName=ProxyProtocol,AttributeValue=true

aws elb set-load-balancer-policies-for-backend-server --load-balancer-name dxxx --instance-port 443 --policy-names realIPProxyProtocol
aws elb set-load-balancer-policies-for-backend-server --load-balancer-name exxx --instance-port 80 --policy-names realIPProxyProtocol
aws elb describe-load-balancers --load-balancer-name exxx

2 Modify nginx.conf

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_

Guess you like

Origin blog.csdn.net/baidu_31405631/article/details/114134428