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:
parent
6c716b8886
commit
3a08cc3074
4 changed files with 38 additions and 19 deletions
|
@ -9,6 +9,7 @@ include $(TOPDIR)/rules.mk
|
|||
|
||||
LUCI_TITLE:=LuCI Support for nginx load balancing
|
||||
LUCI_DEPENDS:=+nginx
|
||||
KCONFIG:=CONFIG_NGINX_STREAM
|
||||
|
||||
PKG_LICENSE:=MIT
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ else
|
|||
end
|
||||
|
||||
s = m:section(TypedSection, "general", translate("General Setting"))
|
||||
s.anonymous = true
|
||||
s.addremove = true
|
||||
|
||||
o = s:option(Flag, "enable", translate("Enable"))
|
||||
o.rmempty = false
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
|
||||
config general 'general'
|
||||
config general 'ShadowSocks'
|
||||
option enable '0'
|
||||
option retries '1'
|
||||
option timeout '1000'
|
||||
option listen '0.0.0.0:65101'
|
||||
option startup_delay '5'
|
||||
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'
|
||||
|
|
|
@ -49,6 +49,31 @@ start_instance() {
|
|||
|
||||
[ "$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
|
||||
cat <<-EOF > /var/etc/$PROG_NAME.cfg
|
||||
user nobody nogroup;
|
||||
|
@ -62,19 +87,7 @@ start_instance() {
|
|||
}
|
||||
|
||||
stream {
|
||||
upstream allservers {
|
||||
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;
|
||||
}
|
||||
${stream}
|
||||
}
|
||||
EOF
|
||||
|
||||
|
@ -83,11 +96,8 @@ start_instance() {
|
|||
procd_set_param file /var/etc/$PROG_NAME.cfg
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load nginx-ha
|
||||
config_foreach start_instance general
|
||||
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue