nginx proxy protocol how to setup this with elb in front of it.

need your help on nginx proxy protocol as i am not getting visitor client ip. instead getting elb’s ip In nginx logs ec2 server(nginx) ->aws elb proxy_protocol is enabled on elb. when setting same parameter in nginx.conf file it stop listening on 80 and 443 and website not accessible at all. kindly help.

i am not able to get visitor client ip on my website which runs on ec2 instance nginx web server.

when i configure proxy_protocol it dont listen on 80 and 443 and when i remove it it starts listening again and always gives private ip’s generated from aws elb.

kindly help.

Thanks, Rakesh


upstream tarmac { server;}

server { listen 80; server_name;

if ($http_x_forwarded_proto != 'https') {
return 301 https://$server_name$request_uri;

add_header X-Powered-By kratos;


server { listen 443 ssl default_server; listen [::]:443 ssl default_server; server_name;

ssl_certificate /home/deploy/apps/example_com.pem; ssl_certificate_key /home/deploy/genus/genusapp_com.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers AES256+EECDH:AES256+EDH:!aNULL;

#root /dev/null; access_log /var/log/nginx/nginx.access.log; error_log /var/log/nginx/nginx.error.log;

location / { proxy_set_header X-Scheme $scheme; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header Accept-Encoding “”; proxy_set_header X-Real-IP $remote_addr; #proxy_redirect off; proxy_ignore_client_abort on;

proxy_pass https://tarmac
add_header X-Powered-By kratos3;   


Hi All , I am trying to setup ALB->NGINX->ALB->APACHE, the above is nginx config it work fine we ALB is removed in front nginx , but fails to load when ALB attached in front of nginx can help me out in this, please

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.


We’d need to see your configuration before we can see where the issue is. If you’d kindly post the server block(s) in question, we can take a closer look at them and see where the issue is.