Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
d1efcb8f
Commit
d1efcb8f
authored
Oct 01, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(captiveportal, new) work in progress captiveportal Jinja zone template
parent
8f5a725f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
9 deletions
+25
-9
lighttpd-zone.conf
...rvice/templates/OPNsense/Captiveportal/lighttpd-zone.conf
+25
-9
No files found.
src/opnsense/service/templates/OPNsense/Captiveportal/lighttpd-zone.conf
View file @
d1efcb8f
...
@@ -2,14 +2,29 @@
...
@@ -2,14 +2,29 @@
{%
set
cp_zone_item
= [] %}
{%
set
cp_zone_item
= [] %}
{%
for
item
in
OPNsense
.
captiveportal
.
zones
.
zone
%}
{%
for
item
in
OPNsense
.
captiveportal
.
zones
.
zone
%}
{%
if
TARGET_FILTERS
[
'OPNsense.captiveportal.zones.zone.'
~
loop
.
index0
]
or
TARGET_FILTERS
[
'OPNsense.captiveportal.zones.zone'
] %}
{%
if
TARGET_FILTERS
[
'OPNsense.captiveportal.zones.zone.'
~
loop
.
index0
]
or
TARGET_FILTERS
[
'OPNsense.captiveportal.zones.zone'
] %}
{
# found zone, search for interface ip #}
{%
for
intf_tag
in
item
.
interfaces
.
split
(
','
) %}
{%
for
conf_key
,
conf_inf
in
interfaces
.
iteritems
() %}
{%
if
conf_key
==
intf_tag
and
conf_inf
.
ipaddr
!=
'dhcp'
%}
{%
do
item
.
update
({
'interface_ipaddr'
:
conf_inf
.
ipaddr
}) %}
{%
endif
%}
{%
endfor
%}
{%
endfor
%}
{%
do
cp_zone_item
.
append
(
item
) %}
{%
do
cp_zone_item
.
append
(
item
) %}
{%
endif
%}
{%
endif
%}
{%
endfor
%}
{%
endfor
%}
{%
set
cp_zone_item
=
cp_zone_item
[
0
]|
default
(
None
) %}
{%
set
cp_zone_item
=
cp_zone_item
[
0
]|
default
(
None
) %}
{%
if
cp_zone_item
!=
None
%}
{
# generate zone redirect address #}
{%
do
cp_zone_item
.
update
({
'redirect_host'
:
'https://'
+
cp_zone_item
.
interface_ipaddr
+
':'
~ (
cp_zone_item
.
zoneid
|
int
+
8000
) ~
'/index.html?zone='
~
cp_zone_item
.
zoneid
}) %}
{%
do
cp_zone_item
.
update
({
'redirect_host_match'
:
cp_zone_item
.
interface_ipaddr
.
replace
(
'.'
,
'\.'
) ~
':'
~ (
cp_zone_item
.
zoneid
|
int
+
8000
) }) %}
#######################################################
#######################################################
### Captive portal lighttpd.conf BEGIN
### Captive portal zone {{ cp_zone_item.zoneid }} lighttpd.conf BEGIN
### -- listen on port {{ cp_zone_item.zoneid|int + 8000 }} for primary (ssl) connections
### -- forward on port {{ cp_zone_item.zoneid|int + 9000 }} for plain http redirection
#######################################################
#######################################################
#
#
#### modules to load
#### modules to load
...
@@ -51,25 +66,25 @@ server.kbytes-per-second = 0
...
@@ -51,25 +66,25 @@ server.kbytes-per-second = 0
server
.
bind
=
"0.0.0.0"
server
.
bind
=
"0.0.0.0"
#### bind to port
#### bind to port
server
.
port
=
8000
server
.
port
=
{{
cp_zone_item
.
zoneid
|
int
+
8000
}}
##
##
#url.rewrite-once = ( "(.*)" => "/index.html?redirurl=$1" )
#url.rewrite-once = ( "(.*)" => "/index.html?redirurl=$1" )
$
HTTP
[
"host"
] !~
"(.*
10\.211\.55\.100:8000
.*)"
{
$
HTTP
[
"host"
] !~
"(.*
{{cp_zone_item.redirect_host_match}}
.*)"
{
$
HTTP
[
"host"
] =~
"([^:/]+)"
{
$
HTTP
[
"host"
] =~
"([^:/]+)"
{
url
.
redirect
= (
"^(.*)$"
=>
"
https://10.211.55.100:8000/index.html?zone=test
&redirurl=%1$1"
)
url
.
redirect
= (
"^(.*)$"
=>
"
{{cp_zone_item.redirect_host}}
&redirurl=%1$1"
)
}
}
}
}
## redirect http traffic to https
## redirect http traffic to https
$
SERVER
[
"socket"
] ==
":
9000
"
{
$
SERVER
[
"socket"
] ==
":
{{ cp_zone_item.zoneid|int + 9000 }}
"
{
$
HTTP
[
"host"
] =~
"([^:/]+)"
{
$
HTTP
[
"host"
] =~
"([^:/]+)"
{
url
.
redirect
= (
"^(.*)$"
=>
"
https://10.211.55.100:8000/index.html?zone=test
&redirurl=%1$1"
)
url
.
redirect
= (
"^(.*)$"
=>
"
{{cp_zone_item.redirect_host}}
&redirurl=%1$1"
)
}
}
}
}
$
SERVER
[
"socket"
] ==
"[::]:
9000
"
{
$
SERVER
[
"socket"
] ==
"[::]:
{{ cp_zone_item.zoneid|int + 9000 }}
"
{
$
HTTP
[
"host"
] =~
"([^:/]+)"
{
$
HTTP
[
"host"
] =~
"([^:/]+)"
{
url
.
redirect
= (
"(.*)"
=>
"
https://10.211.55.100:8000/index.html?zone=test
&redirurl=%1$1"
)
url
.
redirect
= (
"(.*)"
=>
"
{{cp_zone_item.redirect_host}}
&redirurl=%1$1"
)
}
}
}
}
...
@@ -201,3 +216,4 @@ mimetype.assign = (
...
@@ -201,3 +216,4 @@ mimetype.assign = (
#######################################################
#######################################################
### Captive Portal lighttpd.conf END
### Captive Portal lighttpd.conf END
#######################################################
#######################################################
{%
endif
%}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment