Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to add following block in http context to set $https based on $http_x_forwarded_proto:

map $http_x_forwarded_proto $https {
    default off;
    https on;

But configuration test fails saying:

nginx: [emerg] the duplicate "https" variable in /etc/nginx/nginx.conf:36
nginx: configuration file /etc/nginx/nginx.conf test failed
share|improve this question
Going to ask the obvious... did you declare the variable https already? – Grumpy Jan 3 '13 at 0:03
No. Where and how should I set it. I tried set $https off; but its not allowed here. – cmnajs Jan 3 '13 at 0:07
Post rest of your config. On a side note, I find the naming of a variable "https" quite poor choice, since there's one very close ($http) in nginx that's reserved. – Grumpy Jan 3 '13 at 2:38

There is from a change in versin 1.1.11, where the variable $https became an internal variable.

Since it's now an internal, and the request itself isn't over HTTP, the best way is to pass along this info to the fastcgi handler. Here is what I have in my nginx.conf (via an include)

map $http_x_forwarded_proto $fastcgi_https {
  default '';
  https on;

Then I have the below in the location block handling the fastcgi_pass

fastcgi_param HTTPS $fastcgi_https;
fastcgi_param SERVER_PORT $http_x_forwarded_port;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.