Conditionally set header in proxy

Hello,

I’m doing SSL termination in nginx, and I’d like to set a header such as
“X-Sheme https” ONLY if X-Scheme is not set. The reason is because an
upstream load balancer may have terminated SSL as well, and I don’t want
to
overwrite that value.

Is this possible?

Best,
Mitchell

On Tue, May 17, 2011 at 01:14:30PM -0700, Mitchell H. wrote:

Hello,

I’m doing SSL termination in nginx, and I’d like to set a header such as
“X-Sheme https” ONLY if X-Scheme is not set. The reason is because an
upstream load balancer may have terminated SSL as well, and I don’t want to
overwrite that value.

Is this possible?

nginx-0.9.0+:

http {
map $http_x_scheme $x_scheme {
“” https;
default $http_x_scheme;
}

server {

    location / {

        proxy_set_header  X-Scheme  $x_scheme;


Igor S.