mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 01:39:25 +08:00
@@ -74,7 +74,7 @@ Install_openresty()
|
|||||||
|
|
||||||
OPTIONS=''
|
OPTIONS=''
|
||||||
|
|
||||||
opensslVersion="3.4.4"
|
opensslVersion="3.5.5"
|
||||||
libresslVersion="3.9.1"
|
libresslVersion="3.9.1"
|
||||||
pcreVersion='8.45'
|
pcreVersion='8.45'
|
||||||
if [ "$sysName" == "Darwin" ];then
|
if [ "$sysName" == "Darwin" ];then
|
||||||
@@ -144,7 +144,7 @@ Install_openresty()
|
|||||||
OPTIONS="${OPTIONS} --with-pcre-jit"
|
OPTIONS="${OPTIONS} --with-pcre-jit"
|
||||||
OPTIONS="${OPTIONS} --with-http_gzip_static_module"
|
OPTIONS="${OPTIONS} --with-http_gzip_static_module"
|
||||||
|
|
||||||
|
#zstd
|
||||||
if [ ! -d ${openrestyDir}/zstd-nginx-module ];then
|
if [ ! -d ${openrestyDir}/zstd-nginx-module ];then
|
||||||
cd ${openrestyDir} && wget -O $openrestyDir/zstd-nginx-module.tar.gz https://github.com/tokers/zstd-nginx-module/archive/refs/heads/master.tar.gz
|
cd ${openrestyDir} && wget -O $openrestyDir/zstd-nginx-module.tar.gz https://github.com/tokers/zstd-nginx-module/archive/refs/heads/master.tar.gz
|
||||||
cd ${openrestyDir} && tar -zxvf zstd-nginx-module.tar.gz
|
cd ${openrestyDir} && tar -zxvf zstd-nginx-module.tar.gz
|
||||||
|
|||||||
@@ -43,10 +43,11 @@ def set_proxy():
|
|||||||
name = request.form.get('name', '')
|
name = request.form.get('name', '')
|
||||||
open_proxy = request.form.get('open_proxy', '')
|
open_proxy = request.form.get('open_proxy', '')
|
||||||
open_cors = request.form.get('open_cors','')
|
open_cors = request.form.get('open_cors','')
|
||||||
|
open_http3 = request.form.get('open_http3','')
|
||||||
open_cache = request.form.get('open_cache', '')
|
open_cache = request.form.get('open_cache', '')
|
||||||
cache_time = request.form.get('cache_time', '')
|
cache_time = request.form.get('cache_time', '')
|
||||||
proxy_id = request.form.get('id', '')
|
proxy_id = request.form.get('id', '')
|
||||||
return MwSites.instance().setProxy(site_name,site_from,to,host,name,open_proxy,open_cors,open_cache,cache_time, proxy_id)
|
return MwSites.instance().setProxy(site_name,site_from,to,host,name,open_proxy,open_cors,open_http3,open_cache,cache_time, proxy_id)
|
||||||
|
|
||||||
# 设置代理状态
|
# 设置代理状态
|
||||||
@blueprint.route('/set_proxy_status', endpoint='set_proxy_status', methods=['POST'])
|
@blueprint.route('/set_proxy_status', endpoint='set_proxy_status', methods=['POST'])
|
||||||
|
|||||||
@@ -931,6 +931,22 @@ def isSupportHttp3(version):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def isVhostHasReuseport():
|
||||||
|
vhost_dir = getServerDir() + '/web_conf/nginx/vhost'
|
||||||
|
if not os.path.exists(vhost_dir):
|
||||||
|
return False
|
||||||
|
try:
|
||||||
|
for filename in os.listdir(vhost_dir):
|
||||||
|
if filename.endswith('.conf'):
|
||||||
|
filepath = os.path.join(vhost_dir, filename)
|
||||||
|
content = readFile(filepath)
|
||||||
|
if content and 'quic reuseport' in content:
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def isDebugMode():
|
def isDebugMode():
|
||||||
if isAppleSystem():
|
if isAppleSystem():
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
server
|
server
|
||||||
{
|
{
|
||||||
# reuseport 只能在一个server出现一次
|
|
||||||
listen {$PORT};
|
listen {$PORT};
|
||||||
listen [::]:{$PORT};
|
listen [::]:{$PORT};
|
||||||
server_name {$SERVER_NAME};
|
server_name {$SERVER_NAME};
|
||||||
|
|||||||
@@ -1634,6 +1634,11 @@ function toProxy(siteName, type, obj) {
|
|||||||
<input class='btswitch btswitch-ios' type='checkbox' name='open_cors'>\
|
<input class='btswitch btswitch-ios' type='checkbox' name='open_cors'>\
|
||||||
<label class='btswitch-btn' id='open_cors' for='open_cors' style='float:left'></label>\
|
<label class='btswitch-btn' id='open_cors' for='open_cors' style='float:left'></label>\
|
||||||
</div>\
|
</div>\
|
||||||
|
<div style='display: inline-block'>\
|
||||||
|
<span class='tname' style='position: relative;top: -5px;'>是否H3</span>\
|
||||||
|
<input class='btswitch btswitch-ios' type='checkbox' name='open_http3'>\
|
||||||
|
<label class='btswitch-btn' id='open_http3' for='open_http3' style='float:left'></label>\
|
||||||
|
</div>\
|
||||||
</div>\
|
</div>\
|
||||||
</div>\
|
</div>\
|
||||||
<div class='line'>\
|
<div class='line'>\
|
||||||
@@ -1685,6 +1690,10 @@ function toProxy(siteName, type, obj) {
|
|||||||
$("input[name='open_cors']").prop("checked",true);
|
$("input[name='open_cors']").prop("checked",true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (obj['open_http3'] == 'on'){
|
||||||
|
$("input[name='open_http3']").prop("checked",true);
|
||||||
|
}
|
||||||
|
|
||||||
if (obj['open_proxy'] == 'on'){
|
if (obj['open_proxy'] == 'on'){
|
||||||
$("input[name='open_proxy']").prop("checked",true);
|
$("input[name='open_proxy']").prop("checked",true);
|
||||||
}
|
}
|
||||||
@@ -1747,6 +1756,15 @@ function toProxy(siteName, type, obj) {
|
|||||||
$("input[name='open_cors']").prop("checked",true);
|
$("input[name='open_cors']").prop("checked",true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#open_http3').click(function(){
|
||||||
|
var status = $("input[name='open_http3']").prop("checked")==true?1:0;
|
||||||
|
if(status==1){
|
||||||
|
$("input[name='open_http3']").prop("checked",false);
|
||||||
|
}else{
|
||||||
|
$("input[name='open_http3']").prop("checked",true);
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
yes:function(index,layer_ro){
|
yes:function(index,layer_ro){
|
||||||
var data = $('#form_proxy').serializeArray();
|
var data = $('#form_proxy').serializeArray();
|
||||||
|
|||||||
+22
-5
@@ -554,11 +554,16 @@ class sites(object):
|
|||||||
tmp = re.findall(rep, conf)
|
tmp = re.findall(rep, conf)
|
||||||
if not mw.inArray(tmp, '443'):
|
if not mw.inArray(tmp, '443'):
|
||||||
listen = re.search(rep, conf).group()
|
listen = re.search(rep, conf).group()
|
||||||
|
|
||||||
|
quic_conf = "quic reuseport"
|
||||||
|
if mw.isVhostHasReuseport():
|
||||||
|
quic_conf = "quic"
|
||||||
|
|
||||||
if mw.isSupportHttp3(version):
|
if mw.isSupportHttp3(version):
|
||||||
http_ssl = "\n\tlisten 443 ssl;"
|
http_ssl = "\n\tlisten 443 ssl;"
|
||||||
http_ssl = http_ssl + "\n\tlisten [::]:443 ssl;"
|
http_ssl = http_ssl + "\n\tlisten [::]:443 ssl;"
|
||||||
http_ssl = http_ssl + "\n\tlisten 443 quic;#reuseport"
|
http_ssl = http_ssl + "\n\tlisten 443 "+quic_conf+";"
|
||||||
http_ssl = http_ssl + "\n\tlisten [::]:443 quic;"
|
http_ssl = http_ssl + "\n\tlisten [::]:443 "+quic_conf+";"
|
||||||
http_ssl = http_ssl + "\n\thttp3 on;"
|
http_ssl = http_ssl + "\n\thttp3 on;"
|
||||||
http_ssl = http_ssl + "\n\thttp2 on;"
|
http_ssl = http_ssl + "\n\thttp2 on;"
|
||||||
else:
|
else:
|
||||||
@@ -1484,7 +1489,7 @@ class sites(object):
|
|||||||
mw.writeFile(vhost_file, content)
|
mw.writeFile(vhost_file, content)
|
||||||
|
|
||||||
# 设置 网站 反向代理列表
|
# 设置 网站 反向代理列表
|
||||||
def setProxy(self, site_name, site_from, to, host, name, open_proxy, open_cors, open_cache, cache_time, proxy_id):
|
def setProxy(self, site_name, site_from, to, host, name, open_proxy, open_cors, open_http3,open_cache, cache_time, proxy_id):
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
if site_name == "" or site_from == "" or to == "" or host == "" or name == "":
|
if site_name == "" or site_from == "" or to == "" or host == "" or name == "":
|
||||||
return mw.returnData(False, "必填项不能为空")
|
return mw.returnData(False, "必填项不能为空")
|
||||||
@@ -1539,11 +1544,12 @@ location ^~ {from} {\n\
|
|||||||
proxy_set_header X-Forwarded-Port $server_port;\n\
|
proxy_set_header X-Forwarded-Port $server_port;\n\
|
||||||
\n\
|
\n\
|
||||||
{proxy_cache}\n\
|
{proxy_cache}\n\
|
||||||
|
{http3}\n\
|
||||||
}\n\
|
}\n\
|
||||||
# PROXY-END"
|
# PROXY-END"
|
||||||
|
|
||||||
tpl_proxy_cache = "\n\
|
tpl_proxy_cache = "\n\
|
||||||
if ( $uri ~* \\.(gif|png|jpg|jpeg|css|js|ttf|woff|woff2)$ )\n\
|
if ( $uri ~* \\.(gif|png|jpg|jpeg|css|js|svg|ttf|woff|woff2)$ )\n\
|
||||||
{\n\
|
{\n\
|
||||||
expires {cache_time}m;\n\
|
expires {cache_time}m;\n\
|
||||||
}\n\
|
}\n\
|
||||||
@@ -1554,7 +1560,7 @@ location ^~ {from} {\n\
|
|||||||
"
|
"
|
||||||
tpl_proxy_nocache_bak = "\n\
|
tpl_proxy_nocache_bak = "\n\
|
||||||
set $static_files_app 0; \n\
|
set $static_files_app 0; \n\
|
||||||
if ( $uri ~* \\.(gif|png|jpg|jpeg|css|js|ttf|woff|woff2)$ )\n\
|
if ( $uri ~* \\.(gif|png|jpg|jpeg|css|js|svg|ttf|woff|woff2)$ )\n\
|
||||||
{\n\
|
{\n\
|
||||||
set $static_files_app 1;\n\
|
set $static_files_app 1;\n\
|
||||||
expires 12h;\n\
|
expires 12h;\n\
|
||||||
@@ -1577,6 +1583,10 @@ location ^~ {from} {\n\
|
|||||||
}\n\
|
}\n\
|
||||||
"
|
"
|
||||||
|
|
||||||
|
tpl_proxy_http3 = "\n\
|
||||||
|
add_header Alt-Svc 'h3=\":443\";ma=86400' always;\n\
|
||||||
|
"
|
||||||
|
|
||||||
# replace
|
# replace
|
||||||
if site_from[0] != '/':
|
if site_from[0] != '/':
|
||||||
site_from = '/' + site_from
|
site_from = '/' + site_from
|
||||||
@@ -1596,6 +1606,11 @@ location ^~ {from} {\n\
|
|||||||
else:
|
else:
|
||||||
tpl = tpl.replace("{cors}", '', 999)
|
tpl = tpl.replace("{cors}", '', 999)
|
||||||
|
|
||||||
|
if open_http3 == 'on':
|
||||||
|
tpl = tpl.replace("{http3}", tpl_proxy_http3, 999)
|
||||||
|
else:
|
||||||
|
tpl = tpl.replace("{http3}", '', 999)
|
||||||
|
|
||||||
|
|
||||||
conf_proxy = "{}/{}.conf".format(self.getProxyPath(site_name), proxy_id)
|
conf_proxy = "{}/{}.conf".format(self.getProxyPath(site_name), proxy_id)
|
||||||
conf_bk = "{}/{}.conf.txt".format(self.getProxyPath(site_name), proxy_id)
|
conf_bk = "{}/{}.conf.txt".format(self.getProxyPath(site_name), proxy_id)
|
||||||
@@ -1623,6 +1638,7 @@ location ^~ {from} {\n\
|
|||||||
"cache_time": cache_time,
|
"cache_time": cache_time,
|
||||||
"open_proxy": open_proxy,
|
"open_proxy": open_proxy,
|
||||||
"open_cors": open_cors,
|
"open_cors": open_cors,
|
||||||
|
"open_http3": open_http3,
|
||||||
"id": proxy_id,
|
"id": proxy_id,
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
@@ -1641,6 +1657,7 @@ location ^~ {from} {\n\
|
|||||||
data[dindex]['cache_time'] = cache_time
|
data[dindex]['cache_time'] = cache_time
|
||||||
data[dindex]['open_proxy'] = open_proxy
|
data[dindex]['open_proxy'] = open_proxy
|
||||||
data[dindex]['open_cors'] = open_cors
|
data[dindex]['open_cors'] = open_cors
|
||||||
|
data[dindex]['open_http3'] = open_http3
|
||||||
|
|
||||||
if open_proxy != 'on':
|
if open_proxy != 'on':
|
||||||
os.rename(conf_proxy, conf_bk)
|
os.rename(conf_proxy, conf_bk)
|
||||||
|
|||||||
Reference in New Issue
Block a user