TemaTres-Vocabulary-Server
TemaTres-Vocabulary-Server copied to clipboard
Add option to enforce https
Hello,
Since I use tematres with docker, behind an ingress controller (Nginx Loadbalancer) the function getURLBase is not working as expected because the protocal between my loadbalancer and the docker image is http.
So we have now some mixt-content blocked by browsers.
What do you think about adding an entry into the config.tematres.php ?
Like : CFG["https_enforce"] = true | default to false
And then adapt this piece of code :
function getURLbase()
{
// The line below need to be adapted.
$s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
$protocol = substr(strtolower($_SERVER["SERVER_PROTOCOL"]), 0, strpos(strtolower($_SERVER["SERVER_PROTOCOL"]), "/")) . $s;
$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
$uri = $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI'];
$segments = explode('?', $uri, 2);
$url = $segments[0];
$url_base=substr($url,0,strripos($url,"/")+1);
return $url_base;
}
Hi @T1loc :) yes.. it's can be a useful feature. Something like this? $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; $s = ($CFG["https_enforce"]) ? $_SERVER["HTTPS"] : $s ;
It's ok?
HI @tematres, I don't think so.
For some use case you have this :
client <-https-> loadbalancer <-http-> webserver(s)
When you use $_SERVER["HTTPS"]
on tematres code you check the second one so it will be always http.
If we want to enforce I'll more use something like that:
$s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
$s = ($CFG["https_enforce"]) ? "s" : $s ;