Conditionally set header in proxy

Igor Sysoev igor at
Wed May 18 08:43:36 MSD 2011

On Tue, May 17, 2011 at 01:14:30PM -0700, Mitchell Hashimoto 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?


http {
    map  $http_x_scheme  $x_scheme {
         ""              https;
         default         $http_x_scheme;

    server {

        location / {

            proxy_set_header  X-Scheme  $x_scheme;

Igor Sysoev

More information about the nginx mailing list