Hello,
Some web hosters are providing the possibility to access the web space via a common SSL proxy.
The proxy access in my case (hosteurope) works via an URL in the from: https://[SSL Proxy Host]/[Hosted domain]/[Domain relative path]
With the patch below, it is possible to use dokuwiki with or without such a proxy. The patch and implementation is not very sophisticated, but conceptually it seems to work ;-).
Two things needed to be modified to make it work:
* 1) Make sure URL are written including the SSL prefix
* 2) Use a second cache so that SSL and none-SSL version get the right pages, with the right URLs
Configuration is done using the three variable $ConfSSLPrx_ProxyHost, $ConfSSLPrx_Prefix, $ConfSSLPrx_CacheDir, which the patch puts into the init.php file.
In the dokuwiki directory, the directory data/cache2 needs to be created. The second cache will double the storage required for caching, which may be important to consider in case storage is limited.
Cheers, Oliver
$ diff -ruN init.php.20100402 init.php
--- init.php.20100402 2010-04-02 22:12:00.000000000 +0200
+++ init.php 2010-04-03 19:27:00.000000000 +0200
@@ -137,9 +137,22 @@
// set timezone (as in pre 5.3.0 days)
date_default_timezone_set(@date_default_timezone_get());
+// SSL proxy support: Config
+global $ConfSSLPrx_ProxyHost, $ConfSSLPrx_Prefix, $ConfSSLPrx_CacheDir;
+$ConfSSLPrx_ProxyHost = 'ssl.123.abc';
+$ConfSSLPrx_Prefix = '/your.domain';
+$ConfSSLPrx_CacheDir = 'cache2';
+
// define baseURL
-if(!defined('DOKU_REL')) define('DOKU_REL',getBaseURL(false));
-if(!defined('DOKU_URL')) define('DOKU_URL',getBaseURL(true));
+// SSL proxy support: Construct DOKU_REL and DOKU_URL for use via ssl proxy
+if($_SERVER['HTTP_X_FORWARDED_HOST'] === $ConfSSLPrx_ProxyHost) {
+ if(!defined('DOKU_REL')) define('DOKU_REL',$ConfSSLPrx_Prefix.getBaseURL(false));
+ if(!defined('DOKU_URL')) define('DOKU_URL','https://'.$ConfSSLPrx_ProxyHost.DOKU_REL);
+} else {
+ if(!defined('DOKU_REL')) define('DOKU_REL',getBaseURL(false));
+ if(!defined('DOKU_URL')) define('DOKU_URL',getBaseURL(true));
+}
+
if(!defined('DOKU_BASE')){
if($conf['canonical']){
define('DOKU_BASE',DOKU_URL);
@@ -261,6 +274,12 @@
'lockdir' => 'locks',
'tmpdir' => 'tmp');
+ // SSL proxy support: Use another cache for SSL pages
+ global $ConfSSLPrx_ProxyHost, $ConfSSLPrx_CacheDir;
+ if($_SERVER['HTTP_X_FORWARDED_HOST'] === $ConfSSLPrx_ProxyHost) {
+ $paths['cachedir'] = $ConfSSLPrx_CacheDir;
+ }
+
foreach($paths as $c => $p){
if(empty($conf[$c])) $conf[$c] = $conf['savedir'].'/'.$p;
$conf[$c] = init_path($conf[$c]);