diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc index 7c60e108a3..7eff9393f3 100644 --- a/etc/inc/captiveportal.inc +++ b/etc/inc/captiveportal.inc @@ -457,14 +457,16 @@ function captiveportal_init_webguis($cpcfg) { $cacert = ""; $key = base64_decode($cpcfg['private-key']); /* generate lighttpd configuration */ + $listenporthttps = $cpcfg['listenporthttps'] ? $cpcfg['listenporthttps'] : ($cpcfg['zoneid'] + 1); system_generate_lighty_config("{$g['varetc_path']}/lighty-{$cpzone}-CaptivePortal-SSL.conf", - $cert, $key, $cacert, "lighty-{$cpzone}-CaptivePortal-SSL.pid", $cpcfg['zoneid'] + 1, "/usr/local/captiveportal", + $cert, $key, $cacert, "lighty-{$cpzone}-CaptivePortal-SSL.pid", $listenporthttps, "/usr/local/captiveportal", "cert-portal.pem", "ca-portal.pem", "1", $maxproc, $use_fastcgi, $cpzone); } /* generate lighttpd configuration */ + $listenporthttp = $cpcfg['listenporthttp'] ? $cpcfg['listenporthttp'] : $cpcfg['zoneid']; system_generate_lighty_config("{$g['varetc_path']}/lighty-{$cpzone}-CaptivePortal.conf", - "", "", "", "lighty-{$cpzone}-CaptivePortal.pid", $cpcfg['zoneid'], "/usr/local/captiveportal", + "", "", "", "lighty-{$cpzone}-CaptivePortal.pid", $listenporthttp, "/usr/local/captiveportal", "cert-portal.pem", "ca-portal.pem", "1", $maxproc, $use_fastcgi, $cpzone); /* attempt to start lighttpd */ @@ -604,11 +606,17 @@ EOD; $cprules .= "add {$rulenum} set 1 allow ip from any to table(2) out\n"; $rulenum++; } + + + $listenporthttp = + $config['captiveportal'][$cpzone]['listenporthttp'] ? + $config['captiveportal'][$cpzone]['listenporthttp'] : + $config['captiveportal'][$cpzone]['zoneid']; $cprules .= << 0 && count($cpiflist) > 0) { $cpinterface = implode(" ", $cpiflist); $cpaddresses = implode(" ", $cpiplist); - $portalias = $cpcfg['zoneid'] + 1; - $portalias .= " {$cpcfg['zoneid']}"; + $listenporthttps = $cpcfg['listenporthttps'] ? $cpcfg['listenporthttps'] : ($cpcfg['zoneid'] + 1); + $listenporthttp = $cpcfg['listenporthttp'] ? $cpcfg['listenporthttp'] : $cpcfg['zoneid']; + $portalias = $listenporthttps; + $portalias .= " {$listenporthttp}"; $ipfrules .= "pass in {$log} quick on { {$cpinterface} } proto tcp from any to { {$cpaddresses} } port { {$portalias} } keep state(sloppy)\n"; $ipfrules .= "pass out {$log} quick on { {$cpinterface} } proto tcp from any to any flags any keep state(sloppy)\n"; } diff --git a/usr/local/captiveportal/index.php b/usr/local/captiveportal/index.php index 3048b67cbc..82514d8936 100755 --- a/usr/local/captiveportal/index.php +++ b/usr/local/captiveportal/index.php @@ -59,14 +59,17 @@ if (!$clientip) { exit; } +$listenporthttps = $cpcfg['listenporthttps'] ? $cpcfg['listenporthttps'] : ($cpcfg['zoneid'] + 1); +$listenporthttp = $cpcfg['listenporthttp'] ? $cpcfg['listenporthttp'] : $cpcfg['zoneid']; + if (isset($config['captiveportal'][$cpzone]['httpslogin'])) - $ourhostname = $config['captiveportal'][$cpzone]['httpsname'] . ":" . ($cpcfg['zoneid'] + 1); + $ourhostname = $config['captiveportal'][$cpzone]['httpsname'] . ":" . $listenporthttps; else { $ifip = portal_ip_from_client_ip($clientip); if (!$ifip) - $ourhostname = $config['system']['hostname'] . $config['system']['domain'] . ":{$cpcfg['zoneid']}"; + $ourhostname = $config['system']['hostname'] . $config['system']['domain'] . ":{$listenporthttp}"; else - $ourhostname = "{$ifip}:{$cpcfg['zoneid']}"; + $ourhostname = "{$ifip}:{$listenporthttp}"; } if ($orig_host != $ourhostname) { diff --git a/usr/local/www/services_captiveportal.php b/usr/local/www/services_captiveportal.php index 6ee3da49b8..9a128a718c 100755 --- a/usr/local/www/services_captiveportal.php +++ b/usr/local/www/services_captiveportal.php @@ -896,10 +896,13 @@ function enable_change(enable_change) {