Our setup is the same as yours, only using map
instead of if/set
(as recommended by the nginx devs).
# Sets a $real_scheme variable whose value is the scheme passed by the load
# balancer in X-Forwarded-Proto (if any), defaulting to $scheme.
# Similar to how the HttpRealIp module treats X-Forwarded-For.
map $http_x_forwarded_proto $real_scheme {
default $http_x_forwarded_proto;
'' $scheme;
}
P.S. I agree, a real_scheme
module would be nice!