1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Update nginx-ha luci interface to support multiple stream

This commit is contained in:
Ycarus 2018-06-26 12:10:31 +02:00
parent 6c716b8886
commit 3a08cc3074
4 changed files with 38 additions and 19 deletions

View file

@ -9,6 +9,7 @@ include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI Support for nginx load balancing LUCI_TITLE:=LuCI Support for nginx load balancing
LUCI_DEPENDS:=+nginx LUCI_DEPENDS:=+nginx
KCONFIG:=CONFIG_NGINX_STREAM
PKG_LICENSE:=MIT PKG_LICENSE:=MIT

View file

@ -7,7 +7,7 @@ else
end end
s = m:section(TypedSection, "general", translate("General Setting")) s = m:section(TypedSection, "general", translate("General Setting"))
s.anonymous = true s.addremove = true
o = s:option(Flag, "enable", translate("Enable")) o = s:option(Flag, "enable", translate("Enable"))
o.rmempty = false o.rmempty = false

View file

@ -1,8 +1,16 @@
config general 'general' config general 'ShadowSocks'
option enable '0' option enable '0'
option retries '1' option retries '1'
option timeout '1000' option timeout '1000'
option listen '0.0.0.0:65101' option listen '0.0.0.0:65101'
option startup_delay '5' option startup_delay '5'
list upstreams '1.2.3.4:65101 weight=1 max_fails=3 fail_timeout=30s' list upstreams '1.2.3.4:65101 weight=1 max_fails=3 fail_timeout=30s'
config general 'VPN'
option enable '0'
option retries '1'
option timeout '1000'
option listen '0.0.0.0:65001'
option startup_delay '5'
list upstreams '1.2.3.4:65001 weight=1 max_fails=3 fail_timeout=30s'

View file

@ -49,6 +49,31 @@ start_instance() {
[ "$enable" = 1 ] || return 1 [ "$enable" = 1 ] || return 1
stream="${stream}
upstream ${1} {
zone dynamic 64k;
$(config_list_foreach "${1}" "upstreams" genline_srv)
}
server {
listen ${listen:-0.0.0.0:6666} udp;
proxy_pass ${1};
}
server {
listen ${listen:-0.0.0.0:6666};
proxy_pass ${1};
}
"
}
start_service() {
local stream=""
config_load nginx-ha
config_foreach start_instance general
[ -z "$stream" ] && return
mkdir -p /var/log/nginx
mkdir -p /var/etc mkdir -p /var/etc
cat <<-EOF > /var/etc/$PROG_NAME.cfg cat <<-EOF > /var/etc/$PROG_NAME.cfg
user nobody nogroup; user nobody nogroup;
@ -62,19 +87,7 @@ start_instance() {
} }
stream { stream {
upstream allservers { ${stream}
zone dynamic 64k;
$(config_list_foreach "${1}" "upstreams" genline_srv)
}
server {
listen ${listen:-0.0.0.0:6666} udp;
proxy_pass allservers;
}
server {
listen ${listen:-0.0.0.0:6666};
proxy_pass allservers;
}
} }
EOF EOF
@ -83,11 +96,8 @@ start_instance() {
procd_set_param file /var/etc/$PROG_NAME.cfg procd_set_param file /var/etc/$PROG_NAME.cfg
procd_set_param respawn procd_set_param respawn
procd_close_instance procd_close_instance
}
start_service() {
config_load nginx-ha
config_foreach start_instance general
} }
reload_service() { reload_service() {