I've been putting various things at home behind an Apache SSL reverse proxy; I want the emonpi under /emonpi but the PHP code uses the SCRIPT_NAME to set the base path. Can a minor change like this be considered to make life easier for the next person who tries this?
The settings.php also needs the approriate entry, in my case:
$basepath = "/emonpi";
but a default like this works with no side effects:
$basepath = "";
emonpi $ git diff core.php diff --git a/core.php b/core.php index ad3e728..55765e4 100644 --- a/core.php +++ b/core.php @@ -17,6 +17,8 @@ defined('EMONCMS_EXEC') or die('Restricted access'); function get_application_path() { + global $basepath; + // Default to http protocol $proto = "http"; @@ -30,9 +32,9 @@ function get_application_path() } if( isset( $_SERVER['HTTP_X_FORWARDED_SERVER'] )) - $path = dirname("$proto://" . server('HTTP_X_FORWARDED_SERVER') . server('SCRIPT_NAME')) . "/"; + $path = dirname("$proto://" . server('HTTP_X_FORWARDED_SERVER') . $basepath . server('SCRIPT_NAME')) . "/"; else - $path = dirname("$proto://" . server('HTTP_HOST') . server('SCRIPT_NAME')) . "/"; + $path = dirname("$proto://" . server('HTTP_HOST') . $basepath . server('SCRIPT_NAME')) . "/"; return $path; }
For reference, the Apache side needs a little tweaking as well:
... SSLProxyEngine On ProxyPreserveHost On ProxyRequests Off RequestHeader set X-Forwarded-Proto "https" env=HTTPS ProxyPass /emonpi http://emonpi ProxyPassReverse /emonpi http://emonpi ...
Then the emonpi is available at https://FRONTEND.DOMAIN/emonpi/emoncms
Re: Putting an emonpi behind an Apache SSL reverse proxy
Spoke too soon. Feeds page not work. Maybe there are some pages that need more help than the simple change above. Looking.
Edit: It was the "Engine '1' unknown" errors and related, fixed in the other thread. Proxy functional again after the fix.