apache + nginx: PHP HTTPS protocol detection

raw

phork0.php

1
2
3
4
5
6
7
8
9
10
<?php
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])
    && $_SERVER['HTTP_X_FORWARDED_PROTO'] != ''
) {
    $protocol = $_SERVER['HTTP_X_FORWARDED_PROTO'];
} else {
    $protocol = $_SERVER['REQUEST_SCHEME'];
}
$domain = $protocol . '://' . $_SERVER['HTTP_HOST'];
 
Christian Weiske Christian Weiske
owner

History