AWS/ELB

From Ever changing code
< AWS
Revision as of 22:41, 26 March 2019 by Pio2pio (talk | contribs)
Jump to navigation Jump to search

Use Nginx to preserve headers/client IP when working with ELB

If you configure ELB for Http/s then headers forwardes (application layer mode) but if you decide to use TCP load balancing ELB is not not aware of any headers. For this we going to use Nginx to proxy_websocket connections L4 TCP.

sudo apt-get install nginx
systemctl status nginx
tail -f /var/log/nginx/access.log
pip install awscli==1.6.6
aws configure
aws elb describe-load-balancer-policy-types
aws elb create-load-balancer-policy --load-balancer-name linuxacademy-protocol-policy --policy-name "<POLICY NAME>" --policy-type-name ProxyProtocolPolicyType --policy-attributes AttributeName=Proxy Protocol, AttributeValue-true
aws elb describe-load-balancer-policies --load-balancer-name aws "<LOAD BALANCER NAME>"
aws elb set-load-balancer-policies-for-backend-server --load-balancer-name "<LOAD BALANCER NAME>" --instance-port 80 --policy-names linuxacademy-protocol-policy
cd /etc
cd nginx/
vim nginx.conf
systemctl restart nginx