summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2005-12-03 19:40:04 +0000
committerScott Ullrich <sullrich@pfsense.org>2005-12-03 19:40:04 +0000
commiteb0f441c33f992846a4a4aec2b037172ff085fa1 (patch)
treef5f78fe4e9f75baaf7b9b2bd3159489f882e3f5c
parentc54d236c00a12dc978dbb717e83a35103cd0c3a2 (diff)
downloadpfsense-eb0f441c33f992846a4a4aec2b037172ff085fa1.zip
pfsense-eb0f441c33f992846a4a4aec2b037172ff085fa1.tar.gz
Fix captive portal redirects now that we are using LightHTTPD
-rw-r--r--etc/inc/captiveportal.inc2
-rw-r--r--etc/inc/system.inc23
-rwxr-xr-xusr/local/captiveportal/index.php7
3 files changed, 25 insertions, 7 deletions
diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc
index 36c86c5..9505095 100644
--- a/etc/inc/captiveportal.inc
+++ b/etc/inc/captiveportal.inc
@@ -195,7 +195,7 @@ EOD;
/* generate lighttpd configuration */
system_generate_lighty_config("{$g['varetc_path']}/lighty-CaptivePortal.conf",
$cert, $key, "lighty-CaptivePortal.pid", "8000", "/usr/local/captiveportal/",
- "cert-portal.pem", "1", $procs, $use_fastcgi);
+ "cert-portal.pem", "1", $procs, $use_fastcgi, true);
/* attempt to start lighttpd */
$res = mwexec("/usr/local/sbin/lighttpd -f {$g['varetc_path']}/lighty-CaptivePortal.conf");
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index c9a2d3e..04d01d1 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -516,10 +516,17 @@ EOD;
return $res;
}
-function system_generate_lighty_config($filename, $cert, $key, $pid_file,
- $port = 80, $document_root = "/usr/local/www/",
- $cert_location = "cert.pem", $max_procs = 2,
- $max_requests = "1", $fast_cgi_enable = true) {
+function system_generate_lighty_config($filename,
+ $cert,
+ $key,
+ $pid_file,
+ $port = 80,
+ $document_root = "/usr/local/www/",
+ $cert_location = "cert.pem",
+ $max_procs = 2,
+ $max_requests = "1",
+ $fast_cgi_enable = true,
+ $captive_portal = false) {
global $config, $g;
@@ -528,6 +535,11 @@ function system_generate_lighty_config($filename, $cert, $key, $pid_file,
echo "system_generate_lighty_config() being called $mt\n";
}
+ if($captive_portal == true) {
+ $captiveportal = ",\"mod_rewrite\"";
+ $captive_portal_rewrite = "url.rewrite-once = ( \"(.*)\" => \"/index.php?redirurl=$1\" )";
+ }
+
if($port <> "")
$lighty_port = $port;
else
@@ -589,7 +601,7 @@ EOD;
## modules to load
server.modules = (
"mod_access",
- {$module}
+ {$module}{$captiveportal}
)
## Unused modules
@@ -615,6 +627,7 @@ server.modules = (
## a static document-root, for virtual-hosting take look at the
## server.virtual-* options
server.document-root = "{$document_root}"
+{$captive_portal_rewrite}
## where to send error-messages to
#server.errorlog = "/var/log/lighttpd.error.log"
diff --git a/usr/local/captiveportal/index.php b/usr/local/captiveportal/index.php
index bf4ab74..ffa4e5d 100755
--- a/usr/local/captiveportal/index.php
+++ b/usr/local/captiveportal/index.php
@@ -41,7 +41,7 @@ header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$orig_host = $_ENV['HTTP_HOST'];
-$orig_request = $_ENV['CAPTIVE_REQPATH'];
+$orig_request = $_GET['redirurl'];
$lockfile = "{$g['varrun_path']}/captiveportal.lock";
$clientip = $_SERVER['REMOTE_ADDR'];
@@ -166,9 +166,14 @@ EOD;
$redirurl = "http://{$orig_host}{$orig_request}";
$htmltext = str_replace("\$PORTAL_REDIRURL\$", htmlspecialchars($redirurl), $htmltext);
+ echo "<p>Orig_host = {$orig_host} \n";
+ echo "<p>Orig_request = {$orig_request} \n";
+ echo "<p>redirurl = {$redirurl} \n";
+
echo $htmltext;
}
+
exit;
function portal_mac_fixed($clientmac) {
OpenPOWER on IntegriCloud