Hiawatha version: Hiawatha v9.7, cache, IPv6, Monitor, reverse proxy, SSL (1.3.8), URL toolkit, XSLT
Operating System: Debian Linux 3.10.44 #1 SMP Sat Jun 21 11:57:38 CEST 2014 x86_64 GNU/Linux
Hello,
I use semi-sharing hosting (like Webfaction) where Hiawatha is serving PHP sites by listening on local port behind Nginx running as reverse proxy.
Now, I again, have to encounter with Tiki CMS and although some code detecting ports have changed, still it does not work properly and we'd like to fix it once for all.
Here is the part of detecting code:
// Check if behind a Frontend-Proxie/Load-Balancer which rewrites ports
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == "http") {
$_SERVER['SERVER_PORT'] = 80;
} else if($_SERVER['HTTP_X_FORWARDED_PROTO'] == "https") {
$_SERVER['SERVER_PORT'] = 443;
}
}
// check if the current port is not 80 or 443
if (isset($_SERVER['SERVER_PORT'])) {
if (($_SERVER['SERVER_PORT'] != 80) && ($_SERVER['SERVER_PORT'] != 443)) {
if (( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' )) {
$prefs['https_port'] = (int) $_SERVER['SERVER_PORT'];
} else {
$prefs['http_port'] = (int) $_SERVER['SERVER_PORT'];
}
}
}
if ( $prefs['https_port'] == 443 )
$prefs['https_port'] = '';
if ( $prefs['http_port'] == 80 )
$prefs['http_port'] = '';
and here you can see snippet from the log file:
127.0.0.1|Fri 10 Oct 2014 15:14:25 +0200|200|88044||GET /lib/jquery_tiki/tiki-jquery.js HTTP/1.0|Host: tiki.sites.djangohosting.ch|X-Real-IP: 193.248.193.185|X-Forwarded-For: 193.248.193.185|X_FORWARDED_PROTO: http|X_FORWARDED_PROTOCOL: http|SCHEME: http|Connection: close|User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0|Accept: */*|Accept-Language: en-US,en;q=0.5|Accept-Encoding: gzip, deflate|Referer: http://tiki.sites.djangohosting.ch/tiki-install.php|Pragma: no-cache|Cache-Control: no-cache
Do you have any idea for which header should Tiki code check to properly detect running behind reverse-proxy?
In the
past [www.hiawatha-webserver.org] Hugo replied that Hiawatha does not do any redirecting and considering that we do not have root access to possibly change configuration of Nginx (and probably that's not important considering that bunch of other apps/CMS-es worked fine), the only option is to add proper logic to Tiki to adjust to its working environment.
Any hint?