I've woken up this morning to find that a new Nginx server I've been teaching myself with is no longer serving websites. It looks like this is because Nginx is no longer running. When I try to start it though, I get this error:

Starting nginx: nginx: [emerg] unknown "https" variable
[FAILED]

Now as far as I'm aware, nothing has been changed and it was running fine yesterday, but nothing I've looked up so far has helped me find a solution to this.

3 Answers
3

Add this to your Nginx config within http {}. The problem with older Nginx versions is that the variable is not defined. This defines the variable.

map $scheme $fastcgi_https {
default off;
https on;
}

Not having $_SERVER['HTTPS'] set will not keep SSL from working in general but will send Magento into an infinite redirect loop on secure pages. Magento does a check to see if the current page should be secure, then checks if it is actually secure. If not, it redirects to the secure URL. The problem is that this check checks for the presence of $_SERVER['HTTPS'].

in the event Google brings someone in my situation here, like it did me:

I am running Nginx 1.2.7 on our ubuntu dev server and just went through exactly this. I got the conf file from the Magento wiki and made a couple changes:

» Removed top server section to get rid of the www. rewrites
» changed magento.com to just magento
» near line 51 (as shown on that link above), I commented out the line with the offending variable.# fastcgi_param HTTPS $fastcgi_https;
» executed sudo service nginx restart

And now my Magento 1.7.0.2 install could march forward. If you're here and you're getting a 404 error on Magento install, you need the above config file.

Update Nginx to version 1.2.7 and so far this does seem to have fixed it. None of the .conf files have changed so I'm assuming there is something in there that was incompatible. I don't know what exactly or why it didn't stop working sooner, but at this stage all seems to be running as it should after updating it.