01225: HTTP_HOST may not always be the proper public URL (HTTP_X_FORWARDED_HOST)

Summary: HTTP_HOST may not always be the proper public URL (HTTP_X_FORWARDED_HOST)
Created: 2010-09-24 11:25
Status: Open
Category: Feature
From: Profiles
Assigned:
Priority: 2
Version: 2.2.18
OS: AS/400 / Apache / 5.2.13

Description: Sometimes the public facing web server forwards a request to another CGI process or another internal Web server. In this case, pmwiki will use the environment variable $_SERVER['HTTP_HOST'], which will reflect the internal process/server. Checking for the value HTTP_X_FORWARDED_HOST is a quick fix which will expand the install base for default setups without any extra configuration.

I tried setting $ScriptUrl in local/config.php and this resulted in no change to the output file. Changing pmwiki.php was the only solution which would give me the proper URLs for css and image media.

if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {

    $ScriptUrl = $UrlScheme.'://'.$_SERVER['HTTP_X_FORWARDED_HOST'].$_SERVER['SCRIPT_NAME'];

} else {

    $ScriptUrl = $UrlScheme.'://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];

}