Adding the message to Arnaud Hallais, the only way to get the correct protocol on my localhost (apache / mac), test server (apache / linux) and production site (iis / win):
define("PROTOCOL", isset($_SERVER['HTTP_X_FORWARDED_PROTO']) ? $_SERVER['HTTP_X_FORWARDED_PROTO'] : ((isset( $_SERVER["HTTPS"] ) && strtolower( $_SERVER["HTTPS"] ) == "on" ) ? 'https' : 'http'));
falux
source share