$https variable?

It would be great if there was an $https variable that was “on” or “off”
(or “”) so you could do something like this:

fastcgi_param HTTPS $https;

Because currently telling PHP https is enabled is much harder,
especially for those that prefer to have a single server{} block for
both HTTP and HTTPS.

Typically PHP uses $_SERVER[‘HTTPS’] === ‘on’ to detect whether or not
HTTPS is enabled.

http://us3.php.net/manual/en/reserved.variables.server.php

Luke

On 24.09.11 11:12, Luke Scott wrote:

It would be great if there was an $https variable that was “on” or
“off” (or “”) so you could do something like this:
fastcgi_param HTTPS $https;
map $scheme $https {
https on;
default off;
}

Igor proposed this a while ago:

on the global level (in http{} block)
map $scheme $php_https { https on; http off; }

then in fastcgi_params
fastcgi_param HTTPS $php_https;

Unfortunately, PHP code in many known packages (such as Moodle)
sometimes relies on the wrong assumption:

$HTTPS = isset($HTTP_SERVER_VARS[‘HTTPS’]) ? $HTTP_SERVER_VARS[‘HTTPS’]
: ‘off’;

Because in Apache HTTPS variable is never submitted at all in http mode
and coders believe this is enough information to check. So, is there a
way to never submit HTTPS=off at all if HTTPS is not present?

Andrejs

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,215756,215941#msg-215941

On 28 Set 2011 12h25 WEST, [email protected] wrote:

Unfortunately, PHP code in many known packages (such as Moodle)
sometimes relies on the wrong assumption:

$HTTPS = isset($HTTP_SERVER_VARS[‘HTTPS’]) ?
$HTTP_SERVER_VARS[‘HTTPS’] : ‘off’;

Because in Apache HTTPS variable is never submitted at all in http
mode and coders believe this is enough information to check. So, is
there a way to never submit HTTPS=off at all if HTTPS is not
present?

map $scheme $php_https {
default ‘’;
https on;
}

fastcgi_param HTTPS $php_https;

— appa

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs