Change proxy_pass protocol accordingly to x-forwarded-proto

Hi,
I have load balancer with SSL on it that connects to nginx servers.
Nginx
servers simply reverse proxy site X.com.
The problem is that nginx servers don’t have SSL certs and listing only
to
unsecured port but it forwards to https protocol.
The question is, can I change proxy_pass URL accordingly to
x-forwarded-proto header?
ex:


x-forwarded-proto = https {
proxy_pass https://X.com
} else {
proxy_pass http://X.com
}


Thanks for any suggestions

Posted at Nginx Forum:

Use ‘map’,
ea:
http://danconnor.com/post/4f65ea41daac4ed031000004/https_ssl_proxying_nginx_to_nginx

Posted at Nginx Forum: