From 9aad09be9aac8f829762907b262e00900d77a5b4 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 13:02:33 +0800 Subject: [PATCH 01/76] Update install.sh --- plugins/openresty/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/openresty/install.sh b/plugins/openresty/install.sh index 722242d57..f4167b951 100755 --- a/plugins/openresty/install.sh +++ b/plugins/openresty/install.sh @@ -12,7 +12,7 @@ export PATH # curl --http3 -v https://www.xxx.com # apt install ncat -y -# nc -u -v www.xxmhaa.com 443 +# nc -u -v www.xx.com 443 # cd /www/server/mdserver-web && python3 plugins/openresty/index.py run_info From f7660391396391f0853fb491d4e2da23d201196b Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 15:01:26 +0800 Subject: [PATCH 02/76] caddy --- plugins/caddy/check.sh | 35 ++ plugins/caddy/conf/Caddyfile | 13 + plugins/caddy/ico.png | Bin 0 -> 3613 bytes plugins/caddy/index.html | 24 ++ plugins/caddy/index.py | 442 +++++++++++++++++++++++++ plugins/caddy/info.json | 18 + plugins/caddy/init.d/caddy.service.tpl | 36 ++ plugins/caddy/init.d/caddy.tpl | 111 +++++++ plugins/caddy/install.sh | 76 +++++ plugins/caddy/js/caddy.js | 238 +++++++++++++ plugins/caddy/tool_task.py | 124 +++++++ plugins/caddy/versions/2.11/install.sh | 87 +++++ 12 files changed, 1204 insertions(+) create mode 100755 plugins/caddy/check.sh create mode 100644 plugins/caddy/conf/Caddyfile create mode 100644 plugins/caddy/ico.png create mode 100755 plugins/caddy/index.html create mode 100755 plugins/caddy/index.py create mode 100755 plugins/caddy/info.json create mode 100644 plugins/caddy/init.d/caddy.service.tpl create mode 100644 plugins/caddy/init.d/caddy.tpl create mode 100755 plugins/caddy/install.sh create mode 100755 plugins/caddy/js/caddy.js create mode 100644 plugins/caddy/tool_task.py create mode 100644 plugins/caddy/versions/2.11/install.sh diff --git a/plugins/caddy/check.sh b/plugins/caddy/check.sh new file mode 100755 index 000000000..4cb2277cc --- /dev/null +++ b/plugins/caddy/check.sh @@ -0,0 +1,35 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin +export PATH + +# OpenResty服务名称 +service_name="caddy" + +# 检查OpenResty是否正在运行 +if systemctl is-active --quiet "$service_name"; then + # 检查是否存在僵尸进程 + zombie_processes=$(ps -ef | grep -i caddy | grep -v grep | awk '{print $2}' | xargs ps -o state= -p 2>/dev/null | grep -c Z) + if [ "$zombie_processes" -gt 0 ]; then + echo "kill caddy 僵尸进程" + ps -ef|grep caddy| grep -v grep| awk '{print $2}' | xargs kill -9 + echo "检测到OpenResty僵尸进程,正在重启服务..." + systemctl restart "$service_name" + echo "服务已重启" + else + echo "OpenResty运行正常" + fi +else + echo "kill caddy" + ps -ef|grep caddy| grep -v grep| awk '{print $2}' | xargs kill -9 + echo "caddy未运行,正在启动服务..." + systemctl start "$service_name" + echo "服务已启动" +fi + +NGINX_IDS=`ps -ef|grep caddy | grep -v grep| awk '{print $2}'` +if [ "$NGINX_IDS" == "" ];then + ps -ef|grep caddy| grep -v grep| awk '{print $2}' | xargs kill -9 + systemctl start "$service_name" + echo "caddy未运行,正在启动服务..." +fi + diff --git a/plugins/caddy/conf/Caddyfile b/plugins/caddy/conf/Caddyfile new file mode 100644 index 000000000..98594e3a2 --- /dev/null +++ b/plugins/caddy/conf/Caddyfile @@ -0,0 +1,13 @@ +:8080 { + # Set this path to your site's directory. + root * /tmp + + # Enable the static file server. + file_server + + # Another common task is to set up a reverse proxy: + # reverse_proxy localhost:8080 + + # Or serve a PHP site through php-fpm: + # php_fastcgi localhost:9000 +} \ No newline at end of file diff --git a/plugins/caddy/ico.png b/plugins/caddy/ico.png new file mode 100644 index 0000000000000000000000000000000000000000..91071011e85aee787622d851973c98a068ad4159 GIT binary patch literal 3613 zcmV+&4&w2NP)7A#q^;^1#v&fm4=#;J-pDD1Y2ZrVi`U3A@U3KZS6 ztD@@y1{xTNP`7CvI86}MZB#3EY^#wh#i3+b4~h~gzAi8CYaZVz&N<)AB?YJM#l>ju zXlB0OcOJjB&9d1VhpzN`$$D#6z7?#Z~^e7rog@p< zpkepP(f6FlXxOB|LR-=J91RE#Lr1NFPuM-=HaqB|on<#%c9lqLr&8@Vv-Dvnp5KV? zH|Q;59>X~3=m|O**DJOF!<93|c**=o7TW45iO66TqqG4nNBOCvy-{_xTA8l7fr?g< zfk;DSz{!c6<0iJ|mN!3HsDJ!09JsHt^6|e{zah4Xm%Dz07`!YuZISyl# zvA}>z`=kD6s?k`*fRnXV*K}`oI=9=&VkcYc`fg@GyS{RDYp|Qs7aDC60$}?rd2G9^C_x$Fi zMtiOa2|t)2c!Z2rQV9aB=Z&%Bryier>Dlt&$ioYlZ=HK5S=r!w5E2IDQA{Q-3doc) zW~LTWMm(i$Kw~X97aej#uU4WRB|+osdi4kE8yD7+<%EJk6(P?t3986#OtR+9`w!mz z$W>}n&p$W$>@&@Ki=Cy19Gn`ALBo-tHEQvf77G!ekcTR_jdg;ieB2GZRJJw}H0^82 z%J)~Zm4pIc%&B!Wqsp@o9a7O0sEYDyio8SlL39AAU%NclynTPy$x~C$eO=qq+VwfG z7WoTCqsh^b*XZ2X=~|vshLVolWR-K}qf!40C8I;AHZFGR|6V7LVr)8K;?6?{{3#O_bDLg7t?y$-h0Urvcuz_y9 zzH#U7o~KTa?mudx%Eau+eW!k-Ha=Njy6dwHL5H|TW$eBhQ42+nVNY3Aazn3{ZGVWH z_SK~RlXaD3kaGOeF7)78r5O!+Om6D>w}K6fVoR<}^ADPNPe@X_{hr zaN?=o|1*pzPLSP~*CwH33ToYVJkM|+t^a5pIw>Sx&;Zj_G#xzEy{fVWT?h}qtU4F9 z{FgnX!N?Bj1g$}9rceBTqauybzrFG2Z~o0|zxw!xN$UG24%Wt}2o2xQ7Q(!6DqY$a zxxupVP3uZ0zT1Xa(0G-xO_kCE0Z@8h_o|X7Q)IUTAl(ndmUwG{GeGwmJxs{90S7ZCs(qRF#8)i&bpvKV2o;q$r-^TWAw3Lipo_OT#Ou zp86uZ71<)yXt>-n->fg)LvIlDi5LI){;gjeIPp74>f<=sTw9P@27orGh(Ob-JXMv- z(7e*{8wsQFq$`;D#I2I|MU4)X5`u#3$rPm;6`}UF3ucaxbsh>Lh^<9rW zpQJub{pTOPowS>hWnAqGWrIqWO*B{`;=!o#(K?|?8I5c?loUfDBP$mQ3`B=1Q9J>V zB|~G1J7+uZ#4?Hm8~9o8wbOJ%77=pa1ofR!4a zJV?{U4xvdokZJQOI-<)@fv%*g9G0xUm|(U|a4OyVRr|vZc2#oOjzow1N2c1X*1O;N zi>13)Z~gK@b!gYA-~P*_8{c^UyGXf`OE&=96K{yN8iYi9ZmmE=(PO|)n%Ws7*67h- z2_9v}EgxM4sG>QY%>B!`z7M8ueE6f~yPpyxqi?P}XgAiQzKPo4-p%G`frMCs+mN&x zAVV&6lxAdr(ki~|S6lBUFigOhE?r2haGNy%$Vgr!9 z3k8c1rKxwdF$mg6BoSGNqnhdoX7$8Cq%xOn!~_wGwnjl=o{qv5zzkLFktix-eZ%oh zN&(Pj6w6N8mdZm55JT&c8$&DCm!znp0c6t2|I=F`G=Z2dwX}DT8q#&5+H$$GC32aT z5>GhdjK4(U+@T;^1P8P^@D!~DA~A!=Ql-iRlWC^X#Cx#Bhq7-G`HCOoJ_fOsCQET; zbU5!iC^VUSwqeQ}Qx39(nTCrlZNe*Zj7HFY3rPyMNKZw9TG=s^CZ2dGLke^4F(?q! zp{o*cnPL0-s<9>4SK-Jp$`bt({qz7S$V;X+ZuofWwyZVY|O4Fo;>o( z@AZ#P?mT?*;@|z1&=vIbsK%|dP0ElL&|0~2ZS-*lgmH5<^tn0hTaeySjOwvEQiYE<$9{L#SDn)F4ad z;4^B0=qHFQ9GE=mDa9~Ne5Wzb9c6)u0HG>aKm#Uz`*!~cA|_d3?<6OjeD)T ztCOcr=8b8j(PE6cB&}*dGk4*gYw!JY^>@2rq9EQWnoXs2zwcSdP-AM`(9rHPf+k6P z^T9>rMgV<2iBM8HL_=gKEuZr6;JwQuukDvIQol9-$y?{T>-8Pe2Tr~IC$361!`NRw z|2;6u?#aHibfgW-0c*!+UiVlgG^uZ|--tJE2g>kJ6jx4rpG&Ze{hncM$C#J_GJE;l zo89#~Agp|TeeOTrk?T>^KeTg(bM;F;$%<=#G6+hKPJPRkrv*(CC!6y>pz4;=qD2fL z^{G{g`0$pDLVRDD?<5OJl=jS}Px$ zWU-9i4DUWu89E_o(iB^ZKh2tpm@>tS*D(0nhAuNNXIw8aUTugaT&-_#*WUWV9m&{T zj~(ZpAwq99*B)Ym@u!AM1m}n*B@Z^wd}}zQ^ziPN`bJNu3?)smvvI5a;9X3REhLgs z6}81wD}BYJAv9=8Wu186=@*PD85Qk5e8R_>EB7Dx>NgHQebzz=yjfeCzx?i-Aae|f z%Ai51=M-K>txPm9HvM{a=&8as-Nv2ft$)By7h)eUW%;my^W5gGF>5idBTDP$oqJ0k z{bJ9_XEeBK|Jajf|ETa3dXuJjp{@YE|s6q9Z0*Eer} z58Ew9!~V*0XYnkROGiHC3u8K--YQ71z46B2*!1weLm~6Gp!xLuw?Du16SlS&2^&-n zw|K5RGB9JAeZAWQnZ+Y~9>)Rvt zDEOwe`bl&ChgoZta3no6>}#1EYor#4ysSoRI|1{lYSHL8OVuE9SaPOT8<{@jYJ-in zrTWrc^f)m7m3=3FYxKa^(3E=%bAQu2Pkh{MZ!Z3K^TE&3%>@d4F$sqq*)_|#2UQp_ ziiJii6Fr?TscQ`Nn$Ai|;#m%NKS3vih|#vxxBFn<#KCBAx2_DME~OrmZl~K^>ogWS z^*h~-dCXE;H4_BPff;b*3B7a7<%1X*s;be_#I_-=(yT-!flXezbx0hUEO9ck;NmMh zNZ_`+iW8R$M#0+#k?4SsfA^h&uCAqpXjK3z(iLx^3)m) zFQZ6ikctJ~vD8Z+k}gy$VF$6z7omaBm&sp7fZGPyR(P1jACJAMDbXk@lg$9AAppui zezFI&@GJz+s^0vb{?QnQEnkc#@5_9zPzUVNC-|W1k(WU3Pf##(cSY|LA;>Cumfct&+0`+HKBEqKLjb&!=#Fc jf&T>!0Q^q?00960Z0))Z>-YPC00000NkvXXu0mjfpmi8` literal 0 HcmV?d00001 diff --git a/plugins/caddy/index.html b/plugins/caddy/index.html new file mode 100755 index 000000000..92cba9ba6 --- /dev/null +++ b/plugins/caddy/index.html @@ -0,0 +1,24 @@ +
+ +
+
+

服务

+

自启动

+

配置修改

+

负载状态

+

性能调整

+

错误日志

+

维护功能

+
+
+
+
+
+ +
+ + \ No newline at end of file diff --git a/plugins/caddy/index.py b/plugins/caddy/index.py new file mode 100755 index 000000000..fdd445a91 --- /dev/null +++ b/plugins/caddy/index.py @@ -0,0 +1,442 @@ +# coding:utf-8 + +import sys +import io +import os +import time +import threading +import subprocess +import re + + +web_dir = os.getcwd() + "/web" +if os.path.exists(web_dir): + sys.path.append(web_dir) + os.chdir(web_dir) + +import core.mw as mw + +app_debug = False +if mw.isAppleSystem(): + app_debug = True + + +def getPluginName(): + return 'caddy' + + +def getPluginDir(): + return mw.getPluginDir() + '/' + getPluginName() + + +def getServerDir(): + return mw.getServerDir() + '/' + getPluginName() + + +def getInitDFile(): + current_os = mw.getOs() + if current_os == 'darwin': + return '/tmp/' + getPluginName() + + if current_os.startswith('freebsd'): + return '/etc/rc.d/' + getPluginName() + + return '/etc/init.d/' + getPluginName() + + +def getArgs(): + args = sys.argv[2:] + # print(args) + tmp = {} + args_len = len(args) + + if args_len == 1: + t = args[0].strip('{').strip('}') + t = t.split(':',2) + tmp[t[0]] = t[1] + elif args_len > 1: + for i in range(len(args)): + t = args[i].split(':',2) + tmp[t[0]] = t[1] + # print(tmp) + return tmp + + +def checkArgs(data, ck=[]): + for i in range(len(ck)): + if not ck[i] in data: + return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!')) + return (True, mw.returnJson(True, 'ok')) + + +def getConf(): + path = getServerDir() + "/Caddyfile" + return path + + +def getConfTpl(): + path = getPluginDir() + '/conf/Caddyfile' + return path + + +def getInitDTpl(): + path = getPluginDir() + "/init.d/caddy.tpl" + return path + +def initDreplace(): + file_tpl = getInitDTpl() + service_path = mw.getServerDir() + initD_path = getServerDir() + '/init.d' + + # init.d + file_bin = initD_path + '/' + getPluginName() + + if not os.path.exists(initD_path): + os.mkdir(initD_path) + + # initd replace + content = mw.readFile(file_tpl) + content = content.replace('{$SERVER_PATH}', service_path) + mw.writeFile(file_bin, content) + mw.execShell('chmod +x ' + file_bin) + + caddy_file = getConf() + if not os.path.exists(caddy_file): + caddy_file_tpl = getConfTpl() + content = mw.readFile(systemServiceTpl) + content = content.replace('{$SERVER_PATH}', service_path) + mw.writeFile(caddy_file, content) + + # systemd + # /usr/lib/systemd/system + systemDir = mw.systemdCfgDir() + systemService = systemDir + '/caddy.service' + if os.path.exists(systemDir) and not os.path.exists(systemService): + systemServiceTpl = getPluginDir() + '/init.d/caddy.service.tpl' + se_content = mw.readFile(systemServiceTpl) + se_content = se_content.replace('{$SERVER_PATH}', service_path) + mw.writeFile(systemService, se_content) + mw.execShell('systemctl daemon-reload') + + return file_bin + + +def status(): + cmd = "ps -ef|grep 'caddy run' |grep -v grep | grep -v python | awk '{print $2}'" + data = mw.execShell(cmd) + if data[0] == '': + return 'stop' + return 'start' + + +def caddyOp(method): + file = initDreplace() + + current_os = mw.getOs() + if current_os == "darwin": + data = mw.execShell(file + ' ' + method) + if data[1] == '': + return 'ok' + return data[1] + + if current_os.startswith("freebsd"): + data = mw.execShell('service caddy ' + method) + if data[1] == '': + return 'ok' + return data[1] + + data = mw.execShell('systemctl ' + method + ' caddy') + if data[1] == '': + return 'ok' + return data[1] + +def start(): + return caddyOp('start') + + +def stop(): + r = caddyOp('stop') + pid_file = getPidFile() + if os.path.exists(pid_file): + os.remove(pid_file) + return r + + +def restart(): + return restyOp_restart() + + +def reload(): + confReplace() + return caddyOp('reload') + + +def initdStatus(): + current_os = mw.getOs() + if current_os == 'darwin': + return "Apple Computer does not support" + + if current_os.startswith('freebsd'): + initd_bin = getInitDFile() + if os.path.exists(initd_bin): + return 'ok' + + shell_cmd = 'systemctl status caddy | grep loaded | grep "enabled;"' + data = mw.execShell(shell_cmd) + if data[0] == '': + return 'fail' + return 'ok' + + +def initdInstall(): + current_os = mw.getOs() + if current_os == 'darwin': + return "Apple Computer does not support" + + # freebsd initd install + if current_os.startswith('freebsd'): + import shutil + source_bin = initDreplace() + initd_bin = getInitDFile() + shutil.copyfile(source_bin, initd_bin) + mw.execShell('chmod +x ' + initd_bin) + mw.execShell('sysrc ' + getPluginName() + '_enable="YES"') + return 'ok' + + mw.execShell('systemctl enable caddy') + return 'ok' + + +def initdUinstall(): + current_os = mw.getOs() + if current_os == 'darwin': + return "Apple Computer does not support" + + if current_os.startswith('freebsd'): + initd_bin = getInitDFile() + os.remove(initd_bin) + mw.execShell('sysrc ' + getPluginName() + '_enable="NO"') + return 'ok' + + mw.execShell('systemctl disable caddy') + return 'ok' + + +def runInfo(): + op_status = status() + if op_status == 'stop': + return mw.returnJson(False, "未启动!") + + +def errorLogPath(): + return getServerDir() + '/nginx/logs/error.log' + + +def getCfg(): + cfg = getConf() + content = mw.readFile(cfg) + + unitrep = "[kmgKMG]" + cfg_args = [ + {"name": "worker_processes", "ps": "处理进程,auto表示自动,数字表示进程数", 'type': 2}, + {"name": "worker_connections", "ps": "最大并发链接数", 'type': 2}, + {"name": "keepalive_timeout", "ps": "连接超时时间", 'type': 2}, + {"name": "zstd", "ps": "是否开启zstd压缩传输", 'type': 1}, + {"name": "brotli", "ps": "是否开启brotli压缩传输", 'type': 1}, + {"name": "gzip", "ps": "是否开启gzip压缩传输", 'type': 1}, + {"name": "gzip_min_length", "ps": "最小压缩文件", 'type': 2}, + {"name": "gzip_comp_level", "ps": "压缩率", 'type': 2}, + {"name": "client_max_body_size", "ps": "最大上传文件", 'type': 2}, + {"name": "server_names_hash_bucket_size", + "ps": "服务器名字的hash表大小", 'type': 2}, + {"name": "client_header_buffer_size", "ps": "客户端请求头buffer大小", 'type': 2}, + ] + + # {"name": "client_body_buffer_size", "ps": "请求主体缓冲区"} + rdata = [] + for i in cfg_args: + rep = r"(%s)\s+(\w+)" % i["name"] + k = re.search(rep, content) + if not k: + return mw.returnJson(False, "获取 key {} 失败".format(k)) + k = k.group(1) + v = re.search(rep, content) + if not v: + return mw.returnJson(False, "获取 value {} 失败".format(v)) + v = v.group(2) + + if re.search(unitrep, v): + u = str.upper(v[-1]) + v = v[:-1] + if len(u) == 1: + psstr = u + "B," + i["ps"] + else: + psstr = u + "," + i["ps"] + else: + u = "" + + kv = {"name": k, "value": v, "unit": u, + "ps": i["ps"], "type": i["type"]} + rdata.append(kv) + + return mw.returnJson(True, "ok", rdata) + +def replaceChar(value, index, new_char): + return value[:index] + new_char + value[index+1:] + +def makeWorkerCpuAffinity(val): + if val == "auto": + return "auto" + + if mw.isNumber(val): + core_num = int(val) + default_core_str = "0"*core_num + core_num_arr = [] + for x in range(core_num): + t = replaceChar(default_core_str, x , "1") + core_num_arr.append(t) + return " ".join(core_num_arr) + + return 'auto' + +def setCfg(): + + args = getArgs() + data = checkArgs(args, [ + 'worker_processes', 'worker_connections', 'keepalive_timeout','zstd','brotli', + 'gzip', 'gzip_min_length', 'gzip_comp_level', 'client_max_body_size', + 'server_names_hash_bucket_size', 'client_header_buffer_size' + ]) + if not data[0]: + return data[1] + + cfg = getConf() + mw.backFile(cfg) + content = mw.readFile(cfg) + + unitrep = "[kmgKMG]" + cfg_args = [ + {"name": "worker_processes", "ps": "处理进程,auto表示自动,数字表示进程数", 'type': 2}, + {"name": "worker_connections", "ps": "最大并发链接数", 'type': 2}, + {"name": "keepalive_timeout", "ps": "连接超时时间", 'type': 2}, + {"name": "zstd", "ps": "是否开启zstd压缩传输", 'type': 1}, + {"name": "brotli", "ps": "是否开启brotli压缩传输", 'type': 1}, + {"name": "gzip", "ps": "是否开启压缩传输", 'type': 1}, + {"name": "gzip_min_length", "ps": "最小压缩文件", 'type': 2}, + {"name": "gzip_comp_level", "ps": "压缩率", 'type': 2}, + {"name": "client_max_body_size", "ps": "最大上传文件", 'type': 2}, + {"name": "server_names_hash_bucket_size", + "ps": "服务器名字的hash表大小", 'type': 2}, + {"name": "client_header_buffer_size", "ps": "客户端请求头buffer大小", 'type': 2}, + ] + + # print(args) + for k, v in args.items(): + # print(k, v) + rep = r"%s\s+[^kKmMgG\;\n]+" % k + if k == "worker_processes" or k == "gzip": + if not re.search(r"auto|on|off|\d+", v): + return mw.returnJson(False, '参数值错误') + elif k == "zstd" or k == "brotli": + if not re.search(r"auto|on|off|\d+", v): + return mw.returnJson(False, '参数值错误') + else: + if not re.search(r"\d+", v): + return mw.returnJson(False, '参数值错误,请输入数字整数') + + if k == "worker_processes" : + k_wca = "worker_cpu_affinity" + rep_wca = r"%s\s+[^\;\n]+" % k_wca + v_wca = makeWorkerCpuAffinity(v) + newconf = "%s %s" % (k_wca, v_wca) + content = re.sub(rep_wca, newconf, content) + + + if re.search(rep, content): + newconf = "%s %s" % (k, v) + content = re.sub(rep, newconf, content) + elif re.search(rep, content): + newconf = "%s %s" % (k, v) + content = re.sub(rep, newconf, content) + + mw.writeFile(cfg, content) + isError = mw.checkWebConfig() + if (isError != True): + mw.restoreFile(cfg) + return mw.returnJson(False, 'ERROR: 配置出错
' + isError.replace("\n", '
') + '
') + + mw.restartWeb() + return mw.returnJson(True, '设置成功') + + +def cronAddCheck(): + try: + import tool_task + tool_task.createBgTask() + return mw.returnJson(True, '添加检查任务成功') + except Exception as e: + return mw.returnJson(False, '添加检查任务失败:'+str(e)) + +def cronDelCheck(): + try: + import tool_task + tool_task.removeBgTask() + return mw.returnJson(True, '删除检查任务成功') + except Exception as e: + return mw.returnJson(False, '删除检查任务失败:'+str(e)) + +def cronCheck(): + return 'ok' + + +def installPreInspection(): + return 'ok' + + +if __name__ == "__main__": + + version = '1.27.1' + version_pl = getServerDir() + "/version.pl" + if os.path.exists(version_pl): + version = mw.readFile(version_pl) + + + func = sys.argv[1] + if func == 'status': + print(status()) + elif func == 'start': + print(start()) + elif func == 'stop': + print(stop()) + elif func == 'restart': + print(restart()) + elif func == 'reload': + print(reload()) + elif func == 'initd_status': + print(initdStatus()) + elif func == 'initd_install': + print(initdInstall()) + elif func == 'initd_uninstall': + print(initdUinstall()) + elif func == 'install_pre_inspection': + print(installPreInspection()) + elif func == 'conf': + print(getConf()) + elif func == 'get_os': + print(getOs()) + elif func == 'run_info': + print(runInfo()) + elif func == 'error_log': + print(errorLogPath()) + elif func == 'get_cfg': + print(getCfg()) + elif func == 'set_cfg': + print(setCfg()) + elif func == 'check': + print(cronCheck()) + elif func == 'cron_add_check': + print(cronAddCheck()) + elif func == 'cron_del_check': + print(cronDelCheck()) + else: + print('error') diff --git a/plugins/caddy/info.json b/plugins/caddy/info.json new file mode 100755 index 000000000..97a69c069 --- /dev/null +++ b/plugins/caddy/info.json @@ -0,0 +1,18 @@ +{ + "sort": 0, + "title":"caddy", + "tip":"soft", + "name":"caddy", + "type":"其他插件", + "ps":"一款功能强大、企业级、开源 Web 服务器,具有用 Go 编写的自动 HTTPS", + "shell":"install.sh", + "install_pre_inspection":true, + "checks":"server/caddy", + "path":"server/caddy", + "author":"caddyserver", + "home":"https://caddyserver.com/", + "date":"2026-04-11", + "pid": "1", + "versions": ["2.11"], + "updates": ["2.11.2"] +} \ No newline at end of file diff --git a/plugins/caddy/init.d/caddy.service.tpl b/plugins/caddy/init.d/caddy.service.tpl new file mode 100644 index 000000000..724eb30d7 --- /dev/null +++ b/plugins/caddy/init.d/caddy.service.tpl @@ -0,0 +1,36 @@ +# caddy.service +# +# For using Caddy with a config file. +# +# Make sure the ExecStart and ExecReload commands are correct +# for your installation. +# +# See https://caddyserver.com/docs/install for instructions. +# +# WARNING: This service does not use the --resume flag, so if you +# use the API to make changes, they will be overwritten by the +# Caddyfile next time the service is restarted. If you intend to +# use Caddy's API to configure it, add the --resume flag to the +# `caddy run` command or use the caddy-api.service file instead. + +[Unit] +Description=Caddy +Documentation=https://caddyserver.com/docs/ +After=network.target network-online.target +Requires=network-online.target + +[Service] +Type=notify +User=caddy +Group=caddy +ExecStart={$SERVER_PATH}/caddy/bin/caddy run --environ --config {$SERVER_PATH}/caddy/Caddyfile +ExecReload={$SERVER_PATH}/caddy/bin/caddy reload --config {$SERVER_PATH}/caddy/Caddyfile --force +TimeoutStopSec=5s +LimitNOFILE=1048576 +LimitNPROC=512 +PrivateTmp=true +ProtectSystem=full +AmbientCapabilities=CAP_NET_BIND_SERVICE + +[Install] +WantedBy=multi-user.target diff --git a/plugins/caddy/init.d/caddy.tpl b/plugins/caddy/init.d/caddy.tpl new file mode 100644 index 000000000..e89186483 --- /dev/null +++ b/plugins/caddy/init.d/caddy.tpl @@ -0,0 +1,111 @@ +#!/bin/sh +# +# /etc/rc.d/init.d/caddy +# +# Runs the caddy +# +# +# chkconfig: - 85 15 +# + +### BEGIN INIT INFO +# Provides: caddy +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Should-Start: caddy +# Should-Stop: caddy +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start caddy at boot time. +# Description: Control caddy. +### END INIT INFO + +# Source function library. +if [ -f /etc/init.d/functions ];then + . /etc/init.d/functions +fi + +if [ -f /etc/rc.d/init.d/functions ];then + . /etc/rc.d/init.d/functions +fi + +# Default values +export HOME={$HOME_DIR} +export USER={$RUN_USER} +NAME=caddy +CADDY_HOME={$SERVER_PATH}/caddy +CADDY_PATH=${CADDY_HOME}/bin/$NAME +CADDY_USER={$RUN_USER} +SERVICENAME="caddy" +LOCKFILE=/tmp/caddy.lock +LOGPATH=${CADDY_HOME}/log +LOGFILE=${LOGPATH}/caddy.log +RETVAL=0 + +if [ -d $LOGPATH ];then + mkdir -p $LOGPATH +fi + +[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME +DAEMON_OPTS="--check $NAME" +[ ! -z "$CADDY_USER" ] && DAEMON_OPTS="$DAEMON_OPTS --user=${CADDY_USER}" + +status(){ + isStart=`ps -ef|grep 'caddy run' |grep -v grep|awk '{print $2}'` + if [ "$isStart" == '' ];then + echo -e "${SERVICENAME} not running" + else + echo -e "${SERVICENAME}(pid $(echo $isStart)) already running" + fi +} + +start() { + isStart=`ps -ef | grep 'caddy run' | grep -v grep | awk '{print $2}'` + if [ "$isStart" != '' ];then + echo "${SERVICENAME}(pid $(echo $isStart)) already running" + return $RETVAL + fi + + cd ${CADDY_HOME} + echo -e "starting ${SERVICENAME}: \c" + ${CADDY_PATH} run --environ --config ${CADDY_HOME}/Caddyfile > ${LOGFILE} 2>&1 & + RETVAL=$? + [ $RETVAL = 0 ] && touch ${LOCKFILE} && echo -e "\033[32mdone\033[0m" + return $RETVAL +} + +stop() { + pids=`ps -ef | grep 'caddy run' | grep -v grep | awk '{print $2}'` + arr=($pids) + echo -e "stopping caddy... \c" + for p in ${arr[@]} + do + kill -9 $p + done + echo -e "\033[32mdone\033[0m" +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + status + ;; + restart) + stop + start + ;; + reload) + stop + start + ;; + *) + echo "Usage: ${NAME} {start|stop|status|restart}" + exit 1 + ;; +esac +exit $RETVAL diff --git a/plugins/caddy/install.sh b/plugins/caddy/install.sh new file mode 100755 index 000000000..cf40b02da --- /dev/null +++ b/plugins/caddy/install.sh @@ -0,0 +1,76 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin +export PATH + +# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/caddy && bash install.sh install 1.21.4 +# cd /www/server/mdserver-web/plugins/caddy && bash install.sh install 1.21.4 +# cd /www/server/mdserver-web/plugins/caddy && bash install.sh install 1.29.2 +# cd /www/server/mdserver-web/plugins/caddy && bash install.sh upgrade 1.29.2 + +# curl -I -H "Accept-Encoding: br" http://localhost +# curl -I -H "Accept-Encoding: zstd" http://localhost +# curl --http3 -v https://www.xxx.com + +# cd /www/server/mdserver-web && python3 plugins/caddy/index.py run_info + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + +sysName=`uname` +action=$1 +type=$2 + +VERSION=$2 +openrestyDir=${serverPath}/source/caddy + +if id www &> /dev/null ;then + echo "www uid is `id -u www`" + echo "www shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `" +else + groupadd www + useradd -g www -s /bin/bash www +fi + +if [ "${action}" == "upgrade" ];then + sh -x $curPath/versions/$2/install.sh $1 + + echo "${VERSION}" > $serverPath/caddy/version.pl + + #初始化 + cd ${rootPath} && python3 ${rootPath}/plugins/caddy/index.py start + cd ${rootPath} && python3 ${rootPath}/plugins/caddy/index.py initd_install + exit 0 +fi + + +if [ "${2}" == "" ];then + echo '缺少安装脚本版本...' + exit 0 +fi + +if [ "${action}" == "uninstall" ];then + if [ -f /usr/lib/systemd/system/caddy.service ] || [ -f /lib/systemd/system/caddy.service ];then + systemctl stop caddy + rm -rf /usr/systemd/system/caddy.service + rm -rf /lib/systemd/system/caddy.service + systemctl daemon-reload + fi + + if [ -f $serverPath/caddy/init.d/caddy ];then + $serverPath/caddy/init.d/caddy stop + fi + + rm -rf $serverPath/caddy +fi + +sh -x $curPath/versions/$2/install.sh $1 + +if [ "${action}" == "install" ] && [ -d $serverPath/caddy ];then + echo "${VERSION}" > $serverPath/caddy/version.pl + + #初始化 + cd ${rootPath} && python3 ${rootPath}/plugins/caddy/index.py start + cd ${rootPath} && python3 ${rootPath}/plugins/caddy/index.py initd_install +fi diff --git a/plugins/caddy/js/caddy.js b/plugins/caddy/js/caddy.js new file mode 100755 index 000000000..3eccb9fce --- /dev/null +++ b/plugins/caddy/js/caddy.js @@ -0,0 +1,238 @@ +function caddyPost(method, args, callback){ + var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); + $.post('/plugins/run', {name:'caddy', func:method, args:JSON.stringify(args)}, function(data) { + layer.close(loadT); + if (!data.status){ + layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']}); + return; + } + + if(typeof(callback) == 'function'){ + callback(data); + } + },'json'); +} + +function orPluginService(_name, version){ + var data = {name:_name, func:'status'} + if ( typeof(version) != 'undefined' ){ + data['version'] = version; + } else { + version = ''; + } + + caddyPost('status', data, function(data){ + if (data.data == 'start'){ + orPluginSetService(_name, true, version); + } else { + orPluginSetService(_name, false, version); + } + }); +} + +function orPluginSetService(_name ,status, version){ + var serviceCon ='

当前状态:'+(status ? '开启' : '关闭' )+ + '

\ + \ + \ + \ +
'; + $(".soft-man-con").html(serviceCon); +} + + +function orPluginOpService(a, b, v,request_callback) { + + var c = "name=" + a + "&func=" + b; + if(v != ''){ + c = c + '&version='+v; + } + + var d = ""; + + switch(b) { + case "stop":d = '停止';break; + case "start":d = '启动';break; + case "restart":d = '重启';break; + case "reload":d = '重载';break; + } + layer.confirm( msgTpl('您真的要{1}{2}{3}服务吗?', [d,a,v]), {icon:3,closeBtn: 2}, function() { + caddyPost('get_os',{},function(data){ + var rdata = $.parseJSON(data.data); + if (!rdata['auth']){ + layer.prompt({title: '检查到权限不足,需要输入密码!', formType: 1},function(pwd, index){ + + layer.close(index); + var data = {'pwd':pwd}; + c += '&args='+JSON.stringify(data); + orPluginOpServiceOp(a,b,c,d,a,v,request_callback); + }); + } else { + orPluginOpServiceOp(a,b,c,d,a,v,request_callback); + + } + }); + }) +} + +function orPluginOpServiceOp(a,b,c,d,a,v,request_callback){ + + var request_path = "/plugins/run"; + if (request_callback == 'yes'){ + request_path = "/plugins/callback"; + } + + var e = layer.msg(msgTpl('正在{1}{2}{3}服务,请稍候...',[d,a,v]), {icon: 16,time: 0}); + $.post(request_path, c, function(g) { + layer.close(e); + + var f = g.data == 'ok' ? msgTpl('{1}{2}服务已{3}',[a,v,d]) : msgTpl('{1}{2}服务{3}失败!',[a,v,d]); + layer.msg(f, {icon: g.data == 'ok' ? 1 : 2}); + + if( b != "reload" && g.data == 'ok' ) { + if ( b == 'start' ) { + orPluginSetService(a, true, v); + } else if ( b == 'stop' ){ + orPluginSetService(a, false, v); + } + } + + if( g.status && g.data != 'ok' ) { + layer.msg(g.data, {icon: 2,time: 10000,shade: 0.3}); + } + + },'json').error(function() { + layer.close(e); + layer.msg('操作异常!', {icon: 2}); + }); +} + + +//查看Nginx负载状态 +function getOpStatus() { + var loadT = layer.msg('正在处理,请稍后...', { icon: 16, time: 0, shade: 0.3 }); + $.post('/plugins/run', {name:'openresty', func:'run_info'}, function(data) { + layer.close(loadT); + try { + var rdata = $.parseJSON(data.data); + if ('status' in rdata && !rdata.status){ + showMsg(rdata.msg, function(){}, null,3000); + return; + } + + var con = "
\ + \ + \ + \ + \ + \ + \ + \ +
活动连接(Active connections)" + rdata.active + "
总连接次数(accepts)" + rdata.accepts + "
总握手次数(handled)" + rdata.handled + "
总请求数(requests)" + rdata.requests + "
请求数(Reading)" + rdata.Reading + "
响应数(Writing)" + rdata.Writing + "
驻留进程(Waiting)" + rdata.Waiting + "
"; + $(".soft-man-con").html(con); + }catch(err){ + showMsg(data.data, function(){}, null,3000); + } + },'json'); +} + + +function setOpCfg(){ + caddyPost('get_cfg', {}, function(data){ + var rdata = $.parseJSON(data.data); + var rdata = rdata.data; + // console.log(rdata); + + var mlist = ''; + for (var i = 0; i < rdata.length; i++) { + var w = '70' + var ibody = ''; + switch (rdata[i].type) { + case 0: + var selected_1 = (rdata[i].value == 1) ? 'selected' : ''; + var selected_0 = (rdata[i].value == 0) ? 'selected' : ''; + ibody = ''; + break; + case 1: + var selected_1 = (rdata[i].value == 'on') ? 'selected' : ''; + var selected_0 = (rdata[i].value == 'off') ? 'selected' : ''; + ibody = ''; + break; + } + mlist += '

' + rdata[i].name + '' + ibody + ""+rdata[i].unit+"" +', ' + rdata[i].ps + '

'; + } + var con = '
\ + ' + mlist + '\ +
\ + \ + \ +
\ +
' + $(".soft-man-con").html(con); + }); +} + +function submitConf() { + var data = { + worker_processes: $("input[name='worker_processes']").val(), + worker_connections: $("input[name='worker_connections']").val(), + keepalive_timeout: $("input[name='keepalive_timeout']").val(), + zstd: $("select[name='zstd']").val() || 'on', + brotli: $("select[name='brotli']").val() || 'on', + gzip: $("select[name='gzip']").val() || 'on', + gzip_min_length: $("input[name='gzip_min_length']").val(), + gzip_comp_level: $("input[name='gzip_comp_level']").val(), + client_max_body_size: $("input[name='client_max_body_size']").val(), + server_names_hash_bucket_size: $("input[name='server_names_hash_bucket_size']").val(), + client_header_buffer_size: $("input[name='client_header_buffer_size']").val(), + }; + + // console.log(data); + caddyPost('set_cfg', data, function(rdata){ + var rdata = $.parseJSON(rdata.data); + // console.log(rdata); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + }); +} + +function otherFunc(){ + var con = '

\ + \ + \ +

'; + $(".soft-man-con").html(con); +} + +function cronAddCheck(){ + caddyPost('cron_add_check', {}, function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + }); +} + +function cronDelCheck(){ + caddyPost('cron_del_check', {}, function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + }); +} + + + + + + + + + + + + diff --git a/plugins/caddy/tool_task.py b/plugins/caddy/tool_task.py new file mode 100644 index 000000000..f20ba8348 --- /dev/null +++ b/plugins/caddy/tool_task.py @@ -0,0 +1,124 @@ +# coding:utf-8 + +import sys +import io +import os +import time +import json + +web_dir = os.getcwd() + "/web" +if os.path.exists(web_dir): + sys.path.append(web_dir) + os.chdir(web_dir) + +import core.mw as mw +from utils.crontab import crontab as MwCrontab + + +app_debug = False +if mw.isAppleSystem(): + app_debug = True + + +def getPluginName(): + return 'caddy' + + +def getPluginDir(): + return mw.getPluginDir() + '/' + getPluginName() + + +def getServerDir(): + return mw.getServerDir() + '/' + getPluginName() + + +def getTaskConf(): + conf = getServerDir() + "/task_config.json" + return conf + + +def getConfigData(): + conf = getTaskConf() + if os.path.exists(conf): + return json.loads(mw.readFile(getTaskConf())) + return { + "task_id": -1, + "period": "minute-n", + "where1": "3", + "hour": "0", + "minute": "0", + } + + +def createBgTask(): + removeBgTask() + createBgTaskByName(getPluginName()) + + +def createBgTaskByName(name): + args = getConfigData() + _name = "[caddy]检查任务" + res = mw.M("crontab").field("id, name").where("name=?", (_name,)).find() + if res: + return True + + if "task_id" in args and args["task_id"] > 0: + res = mw.M("crontab").field("id, name").where( + "id=?", (args["task_id"],)).find() + if res and res["id"] == args["task_id"]: + print("计划任务已经存在!") + return True + + mw_dir = mw.getPanelDir() + cmd = ''' +mw_dir=%s +rname=%s +plugin_path=%s +script_path=%s +''' % (mw_dir, name, getServerDir(), getPluginDir()) + cmd += 'echo "bash $script_path/check.sh"' + "\n" + cmd += 'cd $mw_dir && bash $script_path/check.sh' + "\n" + + params = { + 'name': _name, + 'type': args['period'], + 'week': "", + 'where1': args['where1'], + 'hour': args['hour'], + 'minute': args['minute'], + 'save': "", + 'backup_to': "", + 'stype': "toShell", + 'sname': '', + 'sbody': cmd, + 'url_address': '', + } + + task_id = MwCrontab.instance().add(params) + if task_id > 0: + args["task_id"] = task_id + args["name"] = name + mw.writeFile(getTaskConf(), json.dumps(args)) + + +def removeBgTask(): + cfg = getConfigData() + if "task_id" in cfg and cfg["task_id"] > 0: + res = mw.M("crontab").field("id, name").where( + "id=?", (cfg["task_id"],)).find() + if res and res["id"] == cfg["task_id"]: + data = MwCrontab.instance().delete(cfg["task_id"]) + if data["status"]: + cfg["task_id"] = -1 + mw.writeFile(getTaskConf(), json.dumps(cfg)) + return True + return False + + +if __name__ == "__main__": + if len(sys.argv) > 1: + action = sys.argv[1] + if action == "remove": + removeBgTask() + elif action == "add": + createBgTask() diff --git a/plugins/caddy/versions/2.11/install.sh b/plugins/caddy/versions/2.11/install.sh new file mode 100644 index 000000000..e97027b78 --- /dev/null +++ b/plugins/caddy/versions/2.11/install.sh @@ -0,0 +1,87 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin +export PATH + +# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/caddy && bash install.sh install 2.11 +# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/caddy && bash install.sh upgrade 2.11 +# cd /www/server/mdserver-web/plugins/caddy && bash install.sh install 2.11 + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + +sysName=`uname` +action=$1 +type=$2 + +OS=`uname` +OSNAME='' +case $(uname) in + Darwin) OSNAME="mac" ;; + Linux) OSNAME="linux" ;; +esac + +ARCH=`uname -m` +ARCH_NAME='' +case $(uname -m) in + i386) ARCH_NAME="386" ;; + i686) ARCH_NAME="386" ;; + x86_64) ARCH_NAME="amd64" ;; + arm) ARCH_NAME="arm64" ;; + arm64) ARCH_NAME="arm64" ;; +esac + +VERSION=2.11.2 + +caddyDir=${serverPath}/source/caddy + +Install_App() +{ + if [ "${action}" == "install" ];then + if [ -d $serverPath/caddy ];then + exit 0 + fi + fi + + mkdir -p ${caddyDir} + # mkdir -p ${serverPath}/caddy + echo 'install scripts ...' + + FILE_NAME="caddy_${VERSION}_${OSNAME}_${ARCH_NAME}.tar.gz" + + if [ ! -f ${caddyDir}/${FILE_NAME} ];then + wget --no-check-certificate -O ${caddyDir}/${FILE_NAME} "https://github.com/caddyserver/caddy/releases/download/v${VERSION}/${FILE_NAME}" + fi + + + echo "cd $serverPath/source/caddy/caddy && tar -zxvf ${caddyDir}/$FILE_NAME" + + mkdir -p cd $serverPath/source/caddy/caddy + cd $serverPath/source/caddy/caddy && tar -zxvf ${caddyDir}/$FILE_NAME + if [ "$OSNAME" == "mac" ];then + xattr -cr caddy + fi + + if [ ! -f $serverPath/caddy/bin ];then + mkdir -p $serverPath/caddy/bin + mv $serverPath/source/caddy/caddy/* $serverPath/caddy/bin + chmod +x $serverPath/caddy/bin/caddy + fi + + echo 'Installation of caddy completed' +} + +Uninstall_App() +{ + echo 'Uninstalling caddy completed' +} + +action=$1 +if [ "${1}" == "install" ];then + Install_App +elif [ "${1}" == "upgrade" ];then + Install_App +else + Uninstall_App +fi From 9789ab6e373c2ac793c1702e5b81410ae5ee8912 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 15:04:56 +0800 Subject: [PATCH 03/76] Update index.py --- plugins/caddy/index.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/caddy/index.py b/plugins/caddy/index.py index fdd445a91..3afeb540e 100755 --- a/plugins/caddy/index.py +++ b/plugins/caddy/index.py @@ -69,6 +69,12 @@ def checkArgs(data, ck=[]): return (True, mw.returnJson(True, 'ok')) +def getOs(): + data = {} + data['os'] = mw.getOs() + data['auth'] = True + return mw.getJson(data) + def getConf(): path = getServerDir() + "/Caddyfile" return path @@ -156,9 +162,6 @@ def start(): def stop(): r = caddyOp('stop') - pid_file = getPidFile() - if os.path.exists(pid_file): - os.remove(pid_file) return r From 4fbd037af1c62e5a54701e7da2715f7b557c0c6b Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 16:18:12 +0800 Subject: [PATCH 04/76] update --- plugins/apache/check.sh | 35 ++ plugins/apache/conf/httpd.conf | 109 ++++ plugins/apache/ico.png | Bin 0 -> 1417 bytes plugins/apache/index.html | 24 + plugins/apache/index.py | 644 ++++++++++++++++++++++++ plugins/apache/info.json | 18 + plugins/apache/init.d/httpd.service.tpl | 14 + plugins/apache/init.d/httpd.tpl | 118 +++++ plugins/apache/install.sh | 84 ++++ plugins/apache/js/httpd.js | 238 +++++++++ plugins/apache/tool_task.py | 124 +++++ plugins/apache/versions/2.4/install.sh | 154 ++++++ 12 files changed, 1562 insertions(+) create mode 100755 plugins/apache/check.sh create mode 100644 plugins/apache/conf/httpd.conf create mode 100644 plugins/apache/ico.png create mode 100755 plugins/apache/index.html create mode 100755 plugins/apache/index.py create mode 100755 plugins/apache/info.json create mode 100644 plugins/apache/init.d/httpd.service.tpl create mode 100644 plugins/apache/init.d/httpd.tpl create mode 100755 plugins/apache/install.sh create mode 100755 plugins/apache/js/httpd.js create mode 100644 plugins/apache/tool_task.py create mode 100644 plugins/apache/versions/2.4/install.sh diff --git a/plugins/apache/check.sh b/plugins/apache/check.sh new file mode 100755 index 000000000..e6b36e6de --- /dev/null +++ b/plugins/apache/check.sh @@ -0,0 +1,35 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin +export PATH + +# OpenResty服务名称 +service_name="openresty" + +# 检查OpenResty是否正在运行 +if systemctl is-active --quiet "$service_name"; then + # 检查是否存在僵尸进程 + zombie_processes=$(ps -ef | grep -i openresty | grep -v grep | awk '{print $2}' | xargs ps -o state= -p 2>/dev/null | grep -c Z) + if [ "$zombie_processes" -gt 0 ]; then + echo "kill nginx 僵尸进程" + ps -ef|grep nginx| grep -v grep| awk '{print $2}' | xargs kill -9 + echo "检测到OpenResty僵尸进程,正在重启服务..." + systemctl restart "$service_name" + echo "服务已重启" + else + echo "OpenResty运行正常" + fi +else + echo "kill nginx" + ps -ef|grep nginx| grep -v grep| awk '{print $2}' | xargs kill -9 + echo "OpenResty未运行,正在启动服务..." + systemctl start "$service_name" + echo "服务已启动" +fi + +NGINX_IDS=`ps -ef|grep nginx | grep -v grep| awk '{print $2}'` +if [ "$NGINX_IDS" == "" ];then + ps -ef|grep nginx| grep -v grep| awk '{print $2}' | xargs kill -9 + systemctl start "$service_name" + echo "OpenResty未运行,正在启动服务..." +fi + diff --git a/plugins/apache/conf/httpd.conf b/plugins/apache/conf/httpd.conf new file mode 100644 index 000000000..250e92faf --- /dev/null +++ b/plugins/apache/conf/httpd.conf @@ -0,0 +1,109 @@ +user {$OS_USER} {$OS_USER_GROUP}; +worker_processes auto; +worker_cpu_affinity auto; +error_log {$SERVER_PATH}/openresty/nginx/logs/error.log crit; +pid {$SERVER_PATH}/openresty/nginx/logs/nginx.pid; + +worker_rlimit_nofile 65535; +pcre_jit on; + +events +{ + use {$EVENT_MODEL}; + worker_connections 51200; + multi_accept on; + + # file/video close the mutex lock when under high load + # accept_mutex off; +} + +http +{ + include mime.types; + + include {$SERVER_PATH}/web_conf/nginx/lua/lua.conf; + #include proxy.conf; + + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for" "$request_time"'; + + server_names_hash_bucket_size 32; + client_header_buffer_size 32k; + large_client_header_buffers 4 32k; + client_body_buffer_size 128k; + client_max_body_size 20m; + + # video big file opt + aio threads; + directio 4m; + output_buffers 16 512k; + sendfile on; + tcp_nopush on; + tcp_nodelay on; + + keepalive_timeout 60; + + fastcgi_connect_timeout 60; + fastcgi_send_timeout 60; + fastcgi_read_timeout 60; + fastcgi_buffer_size 64k; + fastcgi_buffers 4 64k; + fastcgi_busy_buffers_size 128k; + fastcgi_temp_file_write_size 256k; + fastcgi_intercept_errors on; + + zstd off; + zstd_comp_level 6; + zstd_min_length 256; + zstd_types text/plain text/css text/xml text/javascript text/cache-manifest text/x-component text/vtt application/javascript application/json application/ld+json application/xml application/xhtml+xml application/rss+xml application/atom+xml application/manifest+json application/x-web-app-manifest+json application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/wasm font/opentype image/svg+xml image/bmp; + + brotli off; + brotli_min_length 256; + brotli_buffers 32 8k; + brotli_comp_level 4; + brotli_window 16m; + brotli_static on; + brotli_types text/plain text/css text/xml text/javascript text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml application/atom+xml application/vnd.ms-fontobject application/x-font-ttf application/x-font-opentype application/x-font-truetype font/tpl font/opentype font/otf font/ttf image/svg+xml image/x-icon image/vnd.microsoft.icon application/wasm application/manifest+json; + + gzip on; + gzip_min_length 1k; + gzip_buffers 4 16k; + gzip_http_version 1.1; + gzip_comp_level 9; + gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml; + gzip_vary on; + gzip_proxied expired no-cache no-store private auth; + gzip_disable "MSIE [1-6]\."; + + + limit_conn_zone $binary_remote_addr zone=perip:10m; + limit_conn_zone $server_name zone=perserver:10m; + + # CACEH_BEGIN + proxy_buffering on; + proxy_buffer_size 1024k; + proxy_buffers 16 1024k; + proxy_busy_buffers_size 2048k; + proxy_temp_file_write_size 2048k; + proxy_cache_path {$SERVER_PATH}/openresty/nginx/proxy_cache_temp levels=1:2 keys_zone=mw_cache:512m inactive=5m max_size=2g use_temp_path=off; + #proxy timeout + proxy_connect_timeout 3s; + proxy_read_timeout 5s; + proxy_send_timeout 5s; + + fastcgi_cache_key "$scheme$request_method$host$request_uri"; + fastcgi_cache_path {$SERVER_PATH}/openresty/nginx/fastcgi_cache_temp levels=1:2 keys_zone=mw_cache_fcgi:100m inactive=60m max_size=5g; + fastcgi_cache_use_stale error timeout invalid_header http_500; + fastcgi_ignore_headers Cache-Control Expires Set-Cookie; + # CACEH_END + + server_tokens off; + access_log /dev/null; + more_set_headers "Server: mdserver-web"; + + include {$SERVER_PATH}/web_conf/nginx/vhost/*.conf; +} + diff --git a/plugins/apache/ico.png b/plugins/apache/ico.png new file mode 100644 index 0000000000000000000000000000000000000000..a679b10266cc18f836cfe0b2cb944e4222b4578f GIT binary patch literal 1417 zcmV;41$O$0P)Px#1ZP1_K>z@;j|==^1pojAGf6~2RA@u(nCWj6WgN%ndFGzkojtnU#U9&BYy&7H z6{LWTQ4UcWj6uPKCcg9kG5!I@nE1lPh(RGlLF7hFI9d>TpWAM?+dbxbo|$>ZY4W@x z(a^mJ$$qlQWS{v?c0Mz|`904p)1*n0mm8LDUl@|eNy&to;y9MKk!#W6=jMe9XdzMC zx2I$1vcSntXLA40UC#}q+lB&yPeN0Y$A`C%oIbH@w6`-F z2tgt8ZdcF9$Z-EBvc$(-kDv_$<>~G%(Qp9~u+kniIW!dNJmIs93<%)XGDc=UKrEzoPo=H4|Mk}JO0utcl(=Gj9qy=re?+V%s(V4U$%YXsS zlvRFmSI=Cg(Tb_7zz31O(E&NSn}tvqLxnu&aF*tatnSxb&9yQ#S}}DK7>=b5 zA5*uFvcWGbW3xyk%i5`gqc$OU+B9ZwmsYOOXjRljpi2t%ol5qcjX^nu0mgr$lGy3Q zRg8gW_$YtFSonFvt!(CfmYNGd2CyF|dPh5iaG%XM#&w)`_G=+Fu6o!5o}EWtY0S+1 zN#j*hbAk6F>5mRXTMzkIRF;IbMMyX`gcXkikasy${=V?&tFq^mXuN7_Dli}<-aH&@ zKj8;=VHM&0EnMszQZ&NyF3wqQ;lj%5#R;qMD2Q%()%jo4OklHg4#zrAwkuK_)WfN9 zum*=!t;o4NV_`@hnz_5@ixb}v#`owUHKAq#N5Xw)4z|P(C^(W{h8r`>4ik`;P$c<|??aGxtkp|)Ry-bQ!QI<1qo|HE!(?vWw^nb^ zculEVV6$|NhWb8xFO?XMx{>a(q}yplWLYf1dl@{tQ~>7H_3ZC7UURAz*r7&We^rj` zT+@k;1S5CLEX8(tNkxH>l_ekKfj)n&ym*1eYfe=HoA0(eg>46SL_)7cNu=wkVObrV zP##Rk>4eC~c?Jl7=yT_SmQ%B?^DI>fgrOK~;l);qIL0E#K6pe5upcDidO_w&CJ%BJ zDP7JlU!?K6P?f+grDd=`r0qZs^fSb?(t-r{w#r?Rm}NlGHm+Ec-(lagX}m5}CGdt8 z-P6Iw24t31CmmDX=0@d-9GQEvffi;BbN15u(s>%K8&wH#o)`w4i?SFy0^vYJ3Q8S# zuH_MQt}yv^$*awR?fc)^YmRZEF-d)Cnx{wl3r3uawHqjjUI zzZOlNF$%$QdCo`4-k|=I5@aj}7r)It{&LzbPXza)?gBw4tPC}*#e?_qFyp!V+uAz! z4yrLm$!rv-3dM=5<@ukG@0v7PS1K+c004_@(*!>0kF~Wc+3vLUE7`bkMW6ejQ76Ai z#U+FhGKuG^0?+S87(Wb*@+;Yur-q>i53XOgiR)P^E}>0CQQXIKT$hc|btzc2A=@?` zj2d?Jt45LK_XCN+;3^1osNq!AMm<6bp6jg!^@8cp%LRlm8a&Jr{o15SlO|1GHW=n# X{5m;3Nc`_U00000NkvXXu0mjfAEKw( literal 0 HcmV?d00001 diff --git a/plugins/apache/index.html b/plugins/apache/index.html new file mode 100755 index 000000000..153330175 --- /dev/null +++ b/plugins/apache/index.html @@ -0,0 +1,24 @@ +
+ +
+
+

服务

+

自启动

+

配置修改

+

负载状态

+

性能调整

+

错误日志

+

维护功能

+
+
+
+
+
+ +
+ + \ No newline at end of file diff --git a/plugins/apache/index.py b/plugins/apache/index.py new file mode 100755 index 000000000..a185e2906 --- /dev/null +++ b/plugins/apache/index.py @@ -0,0 +1,644 @@ +# coding:utf-8 + +import sys +import io +import os +import time +import threading +import subprocess +import re + + +web_dir = os.getcwd() + "/web" +if os.path.exists(web_dir): + sys.path.append(web_dir) + os.chdir(web_dir) + +import core.mw as mw + +app_debug = False +if mw.isAppleSystem(): + app_debug = True + + +def getPluginName(): + return 'apache' + + +def getPluginDir(): + return mw.getPluginDir() + '/' + getPluginName() + + +def getServerDir(): + return mw.getServerDir() + '/' + getPluginName() + + +def getInitDFile(): + current_os = mw.getOs() + if current_os == 'darwin': + return '/tmp/' + getPluginName() + + if current_os.startswith('freebsd'): + return '/etc/rc.d/' + getPluginName() + + return '/etc/init.d/' + getPluginName() + + +def getArgs(): + args = sys.argv[2:] + # print(args) + tmp = {} + args_len = len(args) + + if args_len == 1: + t = args[0].strip('{').strip('}') + t = t.split(':',2) + tmp[t[0]] = t[1] + elif args_len > 1: + for i in range(len(args)): + t = args[i].split(':',2) + tmp[t[0]] = t[1] + # print(tmp) + return tmp + + +def checkArgs(data, ck=[]): + for i in range(len(ck)): + if not ck[i] in data: + return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!')) + return (True, mw.returnJson(True, 'ok')) + + +def clearTemp(): + path_bin = getServerDir() + "/nginx" + mw.execShell('rm -rf ' + path_bin + '/client_body_temp') + mw.execShell('rm -rf ' + path_bin + '/fastcgi_temp') + mw.execShell('rm -rf ' + path_bin + '/proxy_temp') + mw.execShell('rm -rf ' + path_bin + '/scgi_temp') + mw.execShell('rm -rf ' + path_bin + '/uwsgi_temp') + + +def getConf(): + path = getServerDir() + "/nginx/conf/nginx.conf" + return path + + +def getConfTpl(): + path = getPluginDir() + '/conf/nginx.conf' + return path + + +def getOs(): + data = {} + data['os'] = mw.getOs() + ng_exe_bin = getServerDir() + "/nginx/sbin/nginx" + + # if mw.isAppleSystem(): + # data['auth'] = True + # return mw.getJson(data) + + if checkAuthEq(ng_exe_bin, 'root'): + data['auth'] = True + else: + data['auth'] = False + return mw.getJson(data) + + +def getInitDTpl(): + path = getPluginDir() + "/init.d/nginx.tpl" + return path + + +def getPidFile(): + file = getConf() + content = mw.readFile(file) + rep = r'pid\s*(.*);' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + +def getFileOwner(filename): + import pwd + stat = os.lstat(filename) + uid = stat.st_uid + pw = pwd.getpwuid(uid) + return pw.pw_name + + +def checkAuthEq(file, owner='root'): + fowner = getFileOwner(file) + if (fowner == owner): + return True + return False + + +def confReplace(): + service_path = mw.getServerDir() + content = mw.readFile(getConfTpl()) + content = content.replace('{$SERVER_PATH}', service_path) + + user = 'www' + user_group = 'www' + + content = content.replace('{$OS_USER}', user) + content = content.replace('{$OS_USER_GROUP}', user_group) + + # ng_conf_md5 = '' + # ng_conf_md5_file = getServerDir() + '/nginx_conf.md5' + # if not os.path.exists(ng_conf_md5_file): + # ng_conf_md5 = mw.md5(content) + # mw.writeFile(ng_conf_md5_file, ng_conf_md5) + # else: + # ng_conf_md5 = mw.writeFile(ng_conf_md5_file).strip() + + # 主配置文件 + nconf = getServerDir() + '/nginx/conf/nginx.conf' + mw.writeFile(nconf, content) + + # lua配置 + lua_conf_dir = mw.getServerDir() + '/web_conf/nginx/lua' + if not os.path.exists(lua_conf_dir): + mw.execShell('mkdir -p ' + lua_conf_dir) + # 静态配置 + php_conf = mw.getServerDir() + '/web_conf/php/conf' + if not os.path.exists(php_conf): + mw.execShell('mkdir -p ' + php_conf) + static_conf = mw.getServerDir() + '/web_conf/php/conf/enable-php-00.conf' + if not os.path.exists(static_conf): + mw.writeFile(static_conf, 'set $PHP_ENV 0;') + + # vhost + vhost_dir = mw.getServerDir() + '/web_conf/nginx/vhost' + vhost_tpl_dir = getPluginDir() + '/conf/vhost' + if not os.path.exists(vhost_dir): + mw.execShell('mkdir -p ' + vhost_dir) + + vhost_list = ['0.websocket.conf', '0.nginx_status.conf'] + for f in vhost_list: + a_conf = vhost_dir + '/' + f + a_conf_tpl = vhost_tpl_dir + '/' + f + if not os.path.exists(a_conf): + mw.writeFile(a_conf, mw.readFile(a_conf_tpl)) + + +def initDreplace(): + + file_tpl = getInitDTpl() + service_path = mw.getServerDir() + + initD_path = getServerDir() + '/init.d' + + # OpenResty is not installed + if not os.path.exists(getServerDir()): + print("ok") + exit(0) + + # init.d + file_bin = initD_path + '/' + getPluginName() + if not os.path.exists(initD_path): + os.mkdir(initD_path) + + # initd replace + content = mw.readFile(file_tpl) + content = content.replace('{$SERVER_PATH}', service_path) + mw.writeFile(file_bin, content) + mw.execShell('chmod +x ' + file_bin) + + # config replace + confReplace() + + # give nginx root permission + # ng_exe_bin = getServerDir() + "/nginx/sbin/nginx" + # if not checkAuthEq(ng_exe_bin, 'root'): + # user = 'www' + # user_group = 'www' + # current_os = mw.getOs() + # if current_os == 'darwin': + # user = 'root' + # user_group = 'staff' + # args = getArgs() + # if not 'pwd' in args: + # print("权限不足,需要认证启动!") + # exit(0) + + sudoPwd = args['pwd'] + cmd_own = 'chown -R ' + user+':' + user_group + ' ' + ng_exe_bin + mw.execShell('echo %s|sudo -S %s' % (sudoPwd, cmd_own)) + cmd_mod = 'chmod 755 ' + ng_exe_bin + mw.execShell('echo %s|sudo -S %s' % (sudoPwd, cmd_mod)) + cmd_s = 'chmod u+s ' + ng_exe_bin + mw.execShell('echo %s|sudo -S %s' % (sudoPwd, cmd_s)) + + # systemd + # /usr/lib/systemd/system + systemDir = mw.systemdCfgDir() + systemService = systemDir + '/httpd.service' + if os.path.exists(systemDir) and not os.path.exists(systemService): + systemServiceTpl = getPluginDir() + '/init.d/httpd.service.tpl' + se_content = mw.readFile(systemServiceTpl) + se_content = se_content.replace('{$SERVER_PATH}', service_path) + mw.writeFile(systemService, se_content) + mw.execShell('systemctl daemon-reload') + + return file_bin + + +def status(): + pid_file = getPidFile() + if not os.path.exists(pid_file): + return 'stop' + return 'start' + + +def restyOp(method): + file = initDreplace() + + # 启动时,先检查一下配置文件 + check = getServerDir() + "/bin/httpd -t" + check_data = mw.execShell(check) + if not check_data[1].find('test is successful') > -1: + return check_data[1] + + current_os = mw.getOs() + if current_os == "darwin": + data = mw.execShell(file + ' ' + method) + if data[1] == '': + return 'ok' + return data[1] + + if current_os.startswith("freebsd"): + data = mw.execShell('service httpd ' + method) + if data[1] == '': + return 'ok' + return data[1] + + data = mw.execShell('systemctl ' + method + ' httpd') + if data[1] == '': + return 'ok' + return data[1] + + +def op_submit_systemctl_restart(): + current_os = mw.getOs() + if current_os.startswith("freebsd"): + mw.execShell('service httpd restart') + return True + + mw.execShell('systemctl restart httpd') + return True + + +def op_submit_init_restart(file): + mw.execShell(file + ' restart') + + +def restyOp_restart(): + file = initDreplace() + + # 启动时,先检查一下配置文件 + check = getServerDir() + "/bin/httpd -t" + check_data = mw.execShell(check) + if not check_data[1].find('test is successful') > -1: + return 'ERROR: 配置出错
' + check_data[1].replace("\n", '
') + '
' + + if not mw.isAppleSystem(): + threading.Timer(2, op_submit_systemctl_restart).start() + return 'ok' + + threading.Timer(2, op_submit_init_restart, args=(file,)).start() + return 'ok' + + +def start(): + return restyOp('start') + + +def stop(): + r = restyOp('stop') + pid_file = getPidFile() + if os.path.exists(pid_file): + os.remove(pid_file) + return r + + +def restart(): + return restyOp_restart() + + +def reload(): + confReplace() + return restyOp('reload') + + +def initdStatus(): + current_os = mw.getOs() + if current_os == 'darwin': + return "Apple Computer does not support" + + if current_os.startswith('freebsd'): + initd_bin = getInitDFile() + if os.path.exists(initd_bin): + return 'ok' + + shell_cmd = 'systemctl status httpd | grep loaded | grep "enabled;"' + data = mw.execShell(shell_cmd) + if data[0] == '': + return 'fail' + return 'ok' + + +def initdInstall(): + current_os = mw.getOs() + if current_os == 'darwin': + return "Apple Computer does not support" + + # freebsd initd install + if current_os.startswith('freebsd'): + import shutil + source_bin = initDreplace() + initd_bin = getInitDFile() + shutil.copyfile(source_bin, initd_bin) + mw.execShell('chmod +x ' + initd_bin) + mw.execShell('sysrc ' + getPluginName() + '_enable="YES"') + return 'ok' + + mw.execShell('systemctl enable httpd') + return 'ok' + + +def initdUinstall(): + current_os = mw.getOs() + if current_os == 'darwin': + return "Apple Computer does not support" + + if current_os.startswith('freebsd'): + initd_bin = getInitDFile() + os.remove(initd_bin) + mw.execShell('sysrc ' + getPluginName() + '_enable="NO"') + return 'ok' + + mw.execShell('systemctl disable httpd') + return 'ok' + +def getNgxStatusPort(): + ngx_status_file = mw.getServerDir() + '/web_conf/nginx/vhost/0.nginx_status.conf' + content = mw.readFile(ngx_status_file) + rep = r'listen\s*(.*);' + tmp = re.search(rep, content) + port = tmp.groups()[0].strip() + return port + + +def runInfo(): + op_status = status() + if op_status == 'stop': + return mw.returnJson(False, "未启动!") + + port = getNgxStatusPort() + # 取Openresty负载状态 + try: + url = 'http://127.0.0.1:%s/nginx_status' % port + result = mw.httpGet(url, timeout=3) + tmp = result.split() + data = {} + data['active'] = tmp[2] + data['accepts'] = tmp[9] + data['handled'] = tmp[7] + data['requests'] = tmp[8] + data['Reading'] = tmp[11] + data['Writing'] = tmp[13] + data['Waiting'] = tmp[15] + return mw.getJson(data) + except Exception as e: + try: + url = 'http://' + mw.getHostAddr() + ':%s/nginx_status' % port + result = mw.httpGet(url) + tmp = result.split() + data = {} + data['active'] = tmp[2] + data['accepts'] = tmp[9] + data['handled'] = tmp[7] + data['requests'] = tmp[8] + data['Reading'] = tmp[11] + data['Writing'] = tmp[13] + data['Waiting'] = tmp[15] + return mw.getJson(data) + except Exception as e: + return mw.returnJson(False, "oprenresty异常!") + + except Exception as e: + return mw.returnJson(False, "oprenresty not started!") + + +def errorLogPath(): + return getServerDir() + '/nginx/logs/error.log' + + +def getCfg(): + cfg = getConf() + content = mw.readFile(cfg) + + unitrep = "[kmgKMG]" + cfg_args = [ + {"name": "worker_processes", "ps": "处理进程,auto表示自动,数字表示进程数", 'type': 2}, + {"name": "worker_connections", "ps": "最大并发链接数", 'type': 2}, + {"name": "keepalive_timeout", "ps": "连接超时时间", 'type': 2}, + {"name": "zstd", "ps": "是否开启zstd压缩传输", 'type': 1}, + {"name": "brotli", "ps": "是否开启brotli压缩传输", 'type': 1}, + {"name": "gzip", "ps": "是否开启gzip压缩传输", 'type': 1}, + {"name": "gzip_min_length", "ps": "最小压缩文件", 'type': 2}, + {"name": "gzip_comp_level", "ps": "压缩率", 'type': 2}, + {"name": "client_max_body_size", "ps": "最大上传文件", 'type': 2}, + {"name": "server_names_hash_bucket_size", + "ps": "服务器名字的hash表大小", 'type': 2}, + {"name": "client_header_buffer_size", "ps": "客户端请求头buffer大小", 'type': 2}, + ] + + # {"name": "client_body_buffer_size", "ps": "请求主体缓冲区"} + rdata = [] + for i in cfg_args: + rep = r"(%s)\s+(\w+)" % i["name"] + k = re.search(rep, content) + if not k: + return mw.returnJson(False, "获取 key {} 失败".format(k)) + k = k.group(1) + v = re.search(rep, content) + if not v: + return mw.returnJson(False, "获取 value {} 失败".format(v)) + v = v.group(2) + + if re.search(unitrep, v): + u = str.upper(v[-1]) + v = v[:-1] + if len(u) == 1: + psstr = u + "B," + i["ps"] + else: + psstr = u + "," + i["ps"] + else: + u = "" + + kv = {"name": k, "value": v, "unit": u, + "ps": i["ps"], "type": i["type"]} + rdata.append(kv) + + return mw.returnJson(True, "ok", rdata) + +def replaceChar(value, index, new_char): + return value[:index] + new_char + value[index+1:] + +def makeWorkerCpuAffinity(val): + if val == "auto": + return "auto" + + if mw.isNumber(val): + core_num = int(val) + default_core_str = "0"*core_num + core_num_arr = [] + for x in range(core_num): + t = replaceChar(default_core_str, x , "1") + core_num_arr.append(t) + return " ".join(core_num_arr) + + return 'auto' + +def setCfg(): + + args = getArgs() + data = checkArgs(args, [ + 'worker_processes', 'worker_connections', 'keepalive_timeout','zstd','brotli', + 'gzip', 'gzip_min_length', 'gzip_comp_level', 'client_max_body_size', + 'server_names_hash_bucket_size', 'client_header_buffer_size' + ]) + if not data[0]: + return data[1] + + cfg = getConf() + mw.backFile(cfg) + content = mw.readFile(cfg) + + unitrep = "[kmgKMG]" + cfg_args = [ + {"name": "worker_processes", "ps": "处理进程,auto表示自动,数字表示进程数", 'type': 2}, + {"name": "worker_connections", "ps": "最大并发链接数", 'type': 2}, + {"name": "keepalive_timeout", "ps": "连接超时时间", 'type': 2}, + {"name": "zstd", "ps": "是否开启zstd压缩传输", 'type': 1}, + {"name": "brotli", "ps": "是否开启brotli压缩传输", 'type': 1}, + {"name": "gzip", "ps": "是否开启压缩传输", 'type': 1}, + {"name": "gzip_min_length", "ps": "最小压缩文件", 'type': 2}, + {"name": "gzip_comp_level", "ps": "压缩率", 'type': 2}, + {"name": "client_max_body_size", "ps": "最大上传文件", 'type': 2}, + {"name": "server_names_hash_bucket_size", + "ps": "服务器名字的hash表大小", 'type': 2}, + {"name": "client_header_buffer_size", "ps": "客户端请求头buffer大小", 'type': 2}, + ] + + # print(args) + for k, v in args.items(): + # print(k, v) + rep = r"%s\s+[^kKmMgG\;\n]+" % k + if k == "worker_processes" or k == "gzip": + if not re.search(r"auto|on|off|\d+", v): + return mw.returnJson(False, '参数值错误') + elif k == "zstd" or k == "brotli": + if not re.search(r"auto|on|off|\d+", v): + return mw.returnJson(False, '参数值错误') + else: + if not re.search(r"\d+", v): + return mw.returnJson(False, '参数值错误,请输入数字整数') + + if k == "worker_processes" : + k_wca = "worker_cpu_affinity" + rep_wca = r"%s\s+[^\;\n]+" % k_wca + v_wca = makeWorkerCpuAffinity(v) + newconf = "%s %s" % (k_wca, v_wca) + content = re.sub(rep_wca, newconf, content) + + + if re.search(rep, content): + newconf = "%s %s" % (k, v) + content = re.sub(rep, newconf, content) + elif re.search(rep, content): + newconf = "%s %s" % (k, v) + content = re.sub(rep, newconf, content) + + mw.writeFile(cfg, content) + isError = mw.checkWebConfig() + if (isError != True): + mw.restoreFile(cfg) + return mw.returnJson(False, 'ERROR: 配置出错
' + isError.replace("\n", '
') + '
') + + mw.restartWeb() + return mw.returnJson(True, '设置成功') + + +def cronAddCheck(): + try: + import tool_task + tool_task.createBgTask() + return mw.returnJson(True, '添加检查任务成功') + except Exception as e: + return mw.returnJson(False, '添加检查任务失败:'+str(e)) + +def cronDelCheck(): + try: + import tool_task + tool_task.removeBgTask() + return mw.returnJson(True, '删除检查任务成功') + except Exception as e: + return mw.returnJson(False, '删除检查任务失败:'+str(e)) + +def cronCheck(): + return 'ok' + + +def installPreInspection(): + return 'ok' + + +if __name__ == "__main__": + + version = '1.27.1' + version_pl = getServerDir() + "/version.pl" + if os.path.exists(version_pl): + version = mw.readFile(version_pl) + + + func = sys.argv[1] + if func == 'status': + print(status()) + elif func == 'start': + print(start()) + elif func == 'stop': + print(stop()) + elif func == 'restart': + print(restart()) + elif func == 'reload': + print(reload()) + elif func == 'initd_status': + print(initdStatus()) + elif func == 'initd_install': + print(initdInstall()) + elif func == 'initd_uninstall': + print(initdUinstall()) + elif func == 'install_pre_inspection': + print(installPreInspection()) + elif func == 'conf': + print(getConf()) + elif func == 'get_os': + print(getOs()) + elif func == 'run_info': + print(runInfo()) + elif func == 'error_log': + print(errorLogPath()) + elif func == 'get_cfg': + print(getCfg()) + elif func == 'set_cfg': + print(setCfg()) + elif func == 'check': + print(cronCheck()) + elif func == 'cron_add_check': + print(cronAddCheck()) + elif func == 'cron_del_check': + print(cronDelCheck()) + else: + print('error') diff --git a/plugins/apache/info.json b/plugins/apache/info.json new file mode 100755 index 000000000..37fb515fe --- /dev/null +++ b/plugins/apache/info.json @@ -0,0 +1,18 @@ +{ + "sort": 0, + "title":"apache", + "tip":"soft", + "name":"apache", + "type":"其他插件", + "ps":"世界排名第一,快速、可靠并且可通过简单的API扩充", + "shell":"install.sh", + "install_pre_inspection":true, + "checks":"server/apache", + "path":"server/apache", + "author":"apache", + "home":"https://downloads.apache.org/httpd/", + "date":"2026-04-11", + "pid": "1", + "versions": ["2.4"], + "updates": ["2.4:66"] +} \ No newline at end of file diff --git a/plugins/apache/init.d/httpd.service.tpl b/plugins/apache/init.d/httpd.service.tpl new file mode 100644 index 000000000..ac52989a0 --- /dev/null +++ b/plugins/apache/init.d/httpd.service.tpl @@ -0,0 +1,14 @@ +[Unit] +Description=OpenResty is a dynamic web platform based on NGINX and LuaJIT. +After=network.target + +[Service] +Type=forking +ExecStart={$SERVER_PATH}/apache/bin/httpd -c {$SERVER_PATH}/apache/nginx/conf/nginx.conf +ExecStop={$SERVER_PATH}/apache/bin/httpd -s stop +ExecReload={$SERVER_PATH}/apache/bin/httpd -s reload +KillMode=process +Restart=on-failure + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/plugins/apache/init.d/httpd.tpl b/plugins/apache/init.d/httpd.tpl new file mode 100644 index 000000000..d773f931a --- /dev/null +++ b/plugins/apache/init.d/httpd.tpl @@ -0,0 +1,118 @@ +#! /bin/sh +# chkconfig: 2345 55 25 +# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and +# run 'update-rc.d -f nginx defaults', or use the appropriate command on your +# distro. For CentOS/Redhat run: 'chkconfig --add openresty' + +### BEGIN INIT INFO +# Provides: nginx +# Required-Start: $all +# Required-Stop: $all +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: starts the nginx web server +# Description: starts nginx using start-stop-daemon +### END INIT INFO + + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/homebrew/bin +NAME=nginx +NGINX_BIN={$SERVER_PATH}/openresty/bin/openresty +CONFIGFILE={$SERVER_PATH}/openresty/nginx/conf/$NAME.conf +PIDFILE={$SERVER_PATH}/openresty/nginx/logs/$NAME.pid + +case "$1" in + start) + echo -n "Starting $NAME... " + if [ -f $PIDFILE ];then + mPID=`cat $PIDFILE` + isStart=`ps ax | awk '{ print $1 }' | grep -e "^${mPID}$"` + if [ "$isStart" != '' ];then + echo "$NAME (pid `pidof $NAME`) already running." + exit 1 + fi + fi + + $NGINX_BIN -c $CONFIGFILE + + if [ "$?" != 0 ] ; then + echo " failed" + exit 1 + else + echo " done" + fi + ;; + + stop) + echo -n "Stoping $NAME... " + if [ -f $PIDFILE ];then + mPID=`cat $PIDFILE` + isStart=`ps ax | awk '{ print $1 }' | grep -e "^${mPID}$"` + if [ "$isStart" = '' ];then + echo "$NAME is not running." + exit 1 + fi + else + echo "$NAME is not running." + exit 1 + fi + $NGINX_BIN -s stop + + if [ "$?" != 0 ] ; then + echo " failed. Use force-quit" + exit 1 + else + echo " done" + fi + ;; + + status) + if [ -f $PIDFILE ];then + mPID=`cat $PIDFILE` + isStart=`ps ax | awk '{ print $1 }' | grep -e "^${mPID}$"` + if [ "$isStart" != '' ];then + echo "$NAME (pid `pidof $NAME`) already running." + exit 1 + else + echo "$NAME is stopped" + exit 0 + fi + else + echo "$NAME is stopped" + exit 0 + fi + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + + reload) + echo -n "Reload service $NAME... " + if [ -f $PIDFILE ];then + mPID=`cat $PIDFILE` + isStart=`ps ax | awk '{ print $1 }' | grep -e "^${mPID}$"` + if [ "$isStart" != '' ];then + $NGINX_BIN -s reload + echo " done" + else + echo "$NAME is not running, can't reload." + exit 1 + fi + else + echo "$NAME is not running, can't reload." + exit 1 + fi + ;; + + configtest) + echo -n "Test $NAME configure files... " + $NGINX_BIN -t + ;; + + *) + echo "Usage: $0 {start|stop|restart|reload|status|configtest}" + exit 1 + ;; +esac diff --git a/plugins/apache/install.sh b/plugins/apache/install.sh new file mode 100755 index 000000000..76ebcd0f4 --- /dev/null +++ b/plugins/apache/install.sh @@ -0,0 +1,84 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin +export PATH + +# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/apache && bash install.sh install 2.4 +# cd /www/server/mdserver-web/plugins/apache && bash install.sh install 2.4 +# cd /www/server/mdserver-web/plugins/apache && bash install.sh upgrade 2.4 + +# curl -I -H "Accept-Encoding: br" http://localhost +# curl -I -H "Accept-Encoding: zstd" http://localhost +# curl --http3 -v https://www.xxx.com + +# apt install ncat -y +# nc -u -v www.xx.com 443 + +# cd /www/server/mdserver-web && python3 plugins/openresty/index.py run_info + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + +sysName=`uname` +action=$1 +type=$2 + +VERSION=$2 +openrestyDir=${serverPath}/source/apache + +if id www &> /dev/null ;then + echo "www uid is `id -u www`" + echo "www shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `" +else + groupadd www + useradd -g www -s /bin/bash www +fi + +if [ "${action}" == "upgrade" ];then + sh -x $curPath/versions/$2/install.sh $1 + + echo "${VERSION}" > $serverPath/apache/version.pl + + mkdir -p $serverPath/web_conf/php/conf + echo 'set $PHP_ENV 0;' > $serverPath/web_conf/php/conf/enable-php-00.conf + + #初始化 + cd ${rootPath} && python3 ${rootPath}/plugins/apache/index.py start + cd ${rootPath} && python3 ${rootPath}/plugins/apache/index.py initd_install + exit 0 +fi + + +if [ "${2}" == "" ];then + echo '缺少安装脚本版本...' + exit 0 +fi + +if [ "${action}" == "uninstall" ];then + if [ -f /usr/lib/systemd/system/apache.service ] || [ -f /lib/systemd/system/apache.service ];then + systemctl stop apache + rm -rf /usr/systemd/system/apache.service + rm -rf /lib/systemd/system/apache.service + systemctl daemon-reload + fi + + if [ -f $serverPath/apache/init.d/apache ];then + $serverPath/apache/init.d/apache stop + fi + + rm -rf $serverPath/apache +fi + +sh -x $curPath/versions/$2/install.sh $1 + +if [ "${action}" == "install" ] && [ -d $serverPath/apache ];then + echo "${VERSION}" > $serverPath/apache/version.pl + + mkdir -p $serverPath/web_conf/php/conf + echo 'set $PHP_ENV 0;' > $serverPath/web_conf/php/conf/enable-php-00.conf + + #初始化 + cd ${rootPath} && python3 ${rootPath}/plugins/apache/index.py start + cd ${rootPath} && python3 ${rootPath}/plugins/apache/index.py initd_install +fi diff --git a/plugins/apache/js/httpd.js b/plugins/apache/js/httpd.js new file mode 100755 index 000000000..13e318797 --- /dev/null +++ b/plugins/apache/js/httpd.js @@ -0,0 +1,238 @@ +function orPost(method, args, callback){ + var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); + $.post('/plugins/run', {name:'openresty', func:method, args:JSON.stringify(args)}, function(data) { + layer.close(loadT); + if (!data.status){ + layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']}); + return; + } + + if(typeof(callback) == 'function'){ + callback(data); + } + },'json'); +} + +function orPluginService(_name, version){ + var data = {name:_name, func:'status'} + if ( typeof(version) != 'undefined' ){ + data['version'] = version; + } else { + version = ''; + } + + orPost('status', data, function(data){ + if (data.data == 'start'){ + orPluginSetService(_name, true, version); + } else { + orPluginSetService(_name, false, version); + } + }); +} + +function orPluginSetService(_name ,status, version){ + var serviceCon ='

当前状态:'+(status ? '开启' : '关闭' )+ + '

\ + \ + \ + \ +
'; + $(".soft-man-con").html(serviceCon); +} + + +function orPluginOpService(a, b, v,request_callback) { + + var c = "name=" + a + "&func=" + b; + if(v != ''){ + c = c + '&version='+v; + } + + var d = ""; + + switch(b) { + case "stop":d = '停止';break; + case "start":d = '启动';break; + case "restart":d = '重启';break; + case "reload":d = '重载';break; + } + layer.confirm( msgTpl('您真的要{1}{2}{3}服务吗?', [d,a,v]), {icon:3,closeBtn: 2}, function() { + orPost('get_os',{},function(data){ + var rdata = $.parseJSON(data.data); + if (!rdata['auth']){ + layer.prompt({title: '检查到权限不足,需要输入密码!', formType: 1},function(pwd, index){ + + layer.close(index); + var data = {'pwd':pwd}; + c += '&args='+JSON.stringify(data); + orPluginOpServiceOp(a,b,c,d,a,v,request_callback); + }); + } else { + orPluginOpServiceOp(a,b,c,d,a,v,request_callback); + + } + }); + }) +} + +function orPluginOpServiceOp(a,b,c,d,a,v,request_callback){ + + var request_path = "/plugins/run"; + if (request_callback == 'yes'){ + request_path = "/plugins/callback"; + } + + var e = layer.msg(msgTpl('正在{1}{2}{3}服务,请稍候...',[d,a,v]), {icon: 16,time: 0}); + $.post(request_path, c, function(g) { + layer.close(e); + + var f = g.data == 'ok' ? msgTpl('{1}{2}服务已{3}',[a,v,d]) : msgTpl('{1}{2}服务{3}失败!',[a,v,d]); + layer.msg(f, {icon: g.data == 'ok' ? 1 : 2}); + + if( b != "reload" && g.data == 'ok' ) { + if ( b == 'start' ) { + orPluginSetService(a, true, v); + } else if ( b == 'stop' ){ + orPluginSetService(a, false, v); + } + } + + if( g.status && g.data != 'ok' ) { + layer.msg(g.data, {icon: 2,time: 10000,shade: 0.3}); + } + + },'json').error(function() { + layer.close(e); + layer.msg('操作异常!', {icon: 2}); + }); +} + + +//查看Nginx负载状态 +function getOpStatus() { + var loadT = layer.msg('正在处理,请稍后...', { icon: 16, time: 0, shade: 0.3 }); + $.post('/plugins/run', {name:'openresty', func:'run_info'}, function(data) { + layer.close(loadT); + try { + var rdata = $.parseJSON(data.data); + if ('status' in rdata && !rdata.status){ + showMsg(rdata.msg, function(){}, null,3000); + return; + } + + var con = "
\ + \ + \ + \ + \ + \ + \ + \ +
活动连接(Active connections)" + rdata.active + "
总连接次数(accepts)" + rdata.accepts + "
总握手次数(handled)" + rdata.handled + "
总请求数(requests)" + rdata.requests + "
请求数(Reading)" + rdata.Reading + "
响应数(Writing)" + rdata.Writing + "
驻留进程(Waiting)" + rdata.Waiting + "
"; + $(".soft-man-con").html(con); + }catch(err){ + showMsg(data.data, function(){}, null,3000); + } + },'json'); +} + + +function setOpCfg(){ + orPost('get_cfg', {}, function(data){ + var rdata = $.parseJSON(data.data); + var rdata = rdata.data; + // console.log(rdata); + + var mlist = ''; + for (var i = 0; i < rdata.length; i++) { + var w = '70' + var ibody = ''; + switch (rdata[i].type) { + case 0: + var selected_1 = (rdata[i].value == 1) ? 'selected' : ''; + var selected_0 = (rdata[i].value == 0) ? 'selected' : ''; + ibody = ''; + break; + case 1: + var selected_1 = (rdata[i].value == 'on') ? 'selected' : ''; + var selected_0 = (rdata[i].value == 'off') ? 'selected' : ''; + ibody = ''; + break; + } + mlist += '

' + rdata[i].name + '' + ibody + ""+rdata[i].unit+"" +', ' + rdata[i].ps + '

'; + } + var con = '
\ + ' + mlist + '\ +
\ + \ + \ +
\ +
' + $(".soft-man-con").html(con); + }); +} + +function submitConf() { + var data = { + worker_processes: $("input[name='worker_processes']").val(), + worker_connections: $("input[name='worker_connections']").val(), + keepalive_timeout: $("input[name='keepalive_timeout']").val(), + zstd: $("select[name='zstd']").val() || 'on', + brotli: $("select[name='brotli']").val() || 'on', + gzip: $("select[name='gzip']").val() || 'on', + gzip_min_length: $("input[name='gzip_min_length']").val(), + gzip_comp_level: $("input[name='gzip_comp_level']").val(), + client_max_body_size: $("input[name='client_max_body_size']").val(), + server_names_hash_bucket_size: $("input[name='server_names_hash_bucket_size']").val(), + client_header_buffer_size: $("input[name='client_header_buffer_size']").val(), + }; + + // console.log(data); + orPost('set_cfg', data, function(rdata){ + var rdata = $.parseJSON(rdata.data); + // console.log(rdata); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + }); +} + +function otherFunc(){ + var con = '

\ + \ + \ +

'; + $(".soft-man-con").html(con); +} + +function cronAddCheck(){ + orPost('cron_add_check', {}, function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + }); +} + +function cronDelCheck(){ + orPost('cron_del_check', {}, function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + }); +} + + + + + + + + + + + + diff --git a/plugins/apache/tool_task.py b/plugins/apache/tool_task.py new file mode 100644 index 000000000..4be4006f8 --- /dev/null +++ b/plugins/apache/tool_task.py @@ -0,0 +1,124 @@ +# coding:utf-8 + +import sys +import io +import os +import time +import json + +web_dir = os.getcwd() + "/web" +if os.path.exists(web_dir): + sys.path.append(web_dir) + os.chdir(web_dir) + +import core.mw as mw +from utils.crontab import crontab as MwCrontab + + +app_debug = False +if mw.isAppleSystem(): + app_debug = True + + +def getPluginName(): + return 'apache' + + +def getPluginDir(): + return mw.getPluginDir() + '/' + getPluginName() + + +def getServerDir(): + return mw.getServerDir() + '/' + getPluginName() + + +def getTaskConf(): + conf = getServerDir() + "/task_config.json" + return conf + + +def getConfigData(): + conf = getTaskConf() + if os.path.exists(conf): + return json.loads(mw.readFile(getTaskConf())) + return { + "task_id": -1, + "period": "minute-n", + "where1": "3", + "hour": "0", + "minute": "0", + } + + +def createBgTask(): + removeBgTask() + createBgTaskByName(getPluginName()) + + +def createBgTaskByName(name): + args = getConfigData() + _name = "[apache]检查任务" + res = mw.M("crontab").field("id, name").where("name=?", (_name,)).find() + if res: + return True + + if "task_id" in args and args["task_id"] > 0: + res = mw.M("crontab").field("id, name").where( + "id=?", (args["task_id"],)).find() + if res and res["id"] == args["task_id"]: + print("计划任务已经存在!") + return True + + mw_dir = mw.getPanelDir() + cmd = ''' +mw_dir=%s +rname=%s +plugin_path=%s +script_path=%s +''' % (mw_dir, name, getServerDir(), getPluginDir()) + cmd += 'echo "bash $script_path/check.sh"' + "\n" + cmd += 'cd $mw_dir && bash $script_path/check.sh' + "\n" + + params = { + 'name': _name, + 'type': args['period'], + 'week': "", + 'where1': args['where1'], + 'hour': args['hour'], + 'minute': args['minute'], + 'save': "", + 'backup_to': "", + 'stype': "toShell", + 'sname': '', + 'sbody': cmd, + 'url_address': '', + } + + task_id = MwCrontab.instance().add(params) + if task_id > 0: + args["task_id"] = task_id + args["name"] = name + mw.writeFile(getTaskConf(), json.dumps(args)) + + +def removeBgTask(): + cfg = getConfigData() + if "task_id" in cfg and cfg["task_id"] > 0: + res = mw.M("crontab").field("id, name").where( + "id=?", (cfg["task_id"],)).find() + if res and res["id"] == cfg["task_id"]: + data = MwCrontab.instance().delete(cfg["task_id"]) + if data["status"]: + cfg["task_id"] = -1 + mw.writeFile(getTaskConf(), json.dumps(cfg)) + return True + return False + + +if __name__ == "__main__": + if len(sys.argv) > 1: + action = sys.argv[1] + if action == "remove": + removeBgTask() + elif action == "add": + createBgTask() diff --git a/plugins/apache/versions/2.4/install.sh b/plugins/apache/versions/2.4/install.sh new file mode 100644 index 000000000..91d3f5512 --- /dev/null +++ b/plugins/apache/versions/2.4/install.sh @@ -0,0 +1,154 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin +export PATH + +# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/apache && bash install.sh install 2.4 +# cd /www/server/mdserver-web/plugins/apache && bash install.sh install 2.4 + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + +sysName=`uname` +action=$1 +type=$2 + +VERSION=2.4.66 +apacheDir=${serverPath}/source/apache + +Install_App() +{ + if [ "${action}" == "install" ];then + if [ -d $serverPath/apache ];then + exit 0 + fi + fi + + # ----- cpu start ------ + if [ -z "${cpuCore}" ]; then + cpuCore="1" + fi + + if [ -f /proc/cpuinfo ];then + cpuCore=`cat /proc/cpuinfo | grep "processor" | wc -l` + fi + + MEM_INFO=$(free -m|grep Mem|awk '{printf("%.f",($2)/1024)}') + if [ "${cpuCore}" != "1" ] && [ "${MEM_INFO}" != "0" ];then + if [ "${cpuCore}" -gt "${MEM_INFO}" ];then + cpuCore="${MEM_INFO}" + fi + else + cpuCore="1" + fi + + if [ "$cpuCore" -gt "2" ];then + cpuCore=`echo "$cpuCore" | awk '{printf("%.f",($1)*0.8)}'` + else + cpuCore="1" + fi + # ----- cpu end ------ + + mkdir -p ${apacheDir} + echo 'install script ...' + OPTIONS='' + + # 安装 APR 和 APR-util + APR_VERSION=1.7.6 + APR_UTIL_VERSION=1.6.3 + + if [ ! -f ${apacheDir}/apr-${APR_VERSION}.tar.bz2 ];then + wget --no-check-certificate -O ${apacheDir}/apr-${APR_VERSION}.tar.bz2 https://downloads.apache.org/apr/apr-${APR_VERSION}.tar.bz2 -T 3 + fi + + if [ ! -f ${apacheDir}/apr-util-${APR_UTIL_VERSION}.tar.bz2 ];then + wget --no-check-certificate -O ${apacheDir}/apr-util-${APR_UTIL_VERSION}.tar.bz2 https://downloads.apache.org/apr/apr-util-${APR_UTIL_VERSION}.tar.bz2 -T 3 + fi + + # 安装 APR + if [ ! -d ${serverPath}/apache/apr ];then + cd ${apacheDir} && tar -jxf apr-${APR_VERSION}.tar.bz2 + cd ${apacheDir}/apr-${APR_VERSION} && ./configure --prefix=${serverPath}/apache/apr + if [ "$?" == "0" ];then + make -j${cpuCore} && make install + if [ ! -f ${serverPath}/apache/apr/bin/apr-config ];then + echo "APR installation failed: apr-config not found" + exit 1 + fi + else + echo "APR configure failed" + exit 1 + fi + fi + + # 安装 APR-util + if [ ! -d ${serverPath}/apache/apr-util ];then + cd ${apacheDir} && tar -jxf apr-util-${APR_UTIL_VERSION}.tar.bz2 + echo "${apacheDir} && tar -jxf apr-util-${APR_UTIL_VERSION}.tar.bz2" + echo "cd ${apacheDir}/apr-util-${APR_UTIL_VERSION} && ./configure --prefix=${serverPath}/apache/apr-util --with-apr=${serverPath}/apache/apr" + cd ${apacheDir}/apr-util-${APR_UTIL_VERSION} && ./configure --prefix=${serverPath}/apache/apr-util --with-apr=${serverPath}/apache/apr + if [ "$?" == "0" ];then + make -j${cpuCore} && make install + if [ ! -f ${serverPath}/apache/apr-util/bin/apu-config ];then + echo "APR-util installation failed: apu-config not found" + find ${serverPath}/apache/apr-util -name "apu-config" + exit 1 + fi + else + echo "APR-util configure failed" + exit 1 + fi + fi + + if [ ! -f ${apacheDir}/httpd-${VERSION}.tar.bz2 ];then + wget --no-check-certificate -O ${apacheDir}/httpd-${VERSION}.tar.bz2 https://downloads.apache.org/httpd/httpd-${VERSION}.tar.bz2 -T 3 + fi + + if [ ! -d ${apacheDir}/httpd-${VERSION} ];then + cd ${apacheDir} && tar -jxf ${apacheDir}/httpd-${VERSION}.tar.bz2 + fi + + + # 检查 APR 和 APR-util 可执行文件 +APR_CONFIG=$(find ${serverPath}/apache/apr -name "apr-config" | head -1) +APU_CONFIG=$(find ${serverPath}/apache/apr-util -name "apu-config" | head -1) + +if [ -z "$APR_CONFIG" ];then + echo "APR config not found" + exit 1 +fi + +if [ -z "$APU_CONFIG" ];then + echo "APR-util config not found" + exit 1 +fi + +echo "Using APR config: $APR_CONFIG" +echo "Using APR-util config: $APU_CONFIG" + +OPTIONS="${OPTIONS}--with-apr=$APR_CONFIG" +OPTIONS="${OPTIONS} --with-apr-util=$APU_CONFIG" + + cd ${apacheDir}/httpd-${VERSION} && ./configure \ + --prefix=$serverPath/apache \ + $OPTIONS + + make -j${cpuCore} && make install && make clean + + echo 'installation of apache completed' +} + +Uninstall_App() +{ + echo 'uninstalling apache completed' +} + +action=$1 +if [ "${1}" == "install" ];then + Install_App +elif [ "${1}" == "upgrade" ];then + Install_App +else + Uninstall_App +fi From 72188223ae51a4b9e56d17629524c922ec2dc1cc Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 16:19:02 +0800 Subject: [PATCH 05/76] Update install.sh --- plugins/apache/versions/2.4/install.sh | 28 +++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/plugins/apache/versions/2.4/install.sh b/plugins/apache/versions/2.4/install.sh index 91d3f5512..9997d73e2 100644 --- a/plugins/apache/versions/2.4/install.sh +++ b/plugins/apache/versions/2.4/install.sh @@ -111,24 +111,24 @@ Install_App() # 检查 APR 和 APR-util 可执行文件 -APR_CONFIG=$(find ${serverPath}/apache/apr -name "apr-config" | head -1) -APU_CONFIG=$(find ${serverPath}/apache/apr-util -name "apu-config" | head -1) + APR_CONFIG=$(find ${serverPath}/apache/apr -name "apr-config" | head -1) + APU_CONFIG=$(find ${serverPath}/apache/apr-util -name "apu-config" | head -1) -if [ -z "$APR_CONFIG" ];then - echo "APR config not found" - exit 1 -fi + if [ -z "$APR_CONFIG" ];then + echo "APR config not found" + exit 1 + fi -if [ -z "$APU_CONFIG" ];then - echo "APR-util config not found" - exit 1 -fi + if [ -z "$APU_CONFIG" ];then + echo "APR-util config not found" + exit 1 + fi -echo "Using APR config: $APR_CONFIG" -echo "Using APR-util config: $APU_CONFIG" + echo "Using APR config: $APR_CONFIG" + echo "Using APR-util config: $APU_CONFIG" -OPTIONS="${OPTIONS}--with-apr=$APR_CONFIG" -OPTIONS="${OPTIONS} --with-apr-util=$APU_CONFIG" + OPTIONS="${OPTIONS}--with-apr=$APR_CONFIG" + OPTIONS="${OPTIONS} --with-apr-util=$APU_CONFIG" cd ${apacheDir}/httpd-${VERSION} && ./configure \ --prefix=$serverPath/apache \ From 5bb5ad7ba84d9fbcf7633b12256ad1516e8a4b04 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 16:22:08 +0800 Subject: [PATCH 06/76] Update install.sh --- plugins/apache/versions/2.4/install.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/apache/versions/2.4/install.sh b/plugins/apache/versions/2.4/install.sh index 9997d73e2..b584de87c 100644 --- a/plugins/apache/versions/2.4/install.sh +++ b/plugins/apache/versions/2.4/install.sh @@ -136,6 +136,16 @@ Install_App() make -j${cpuCore} && make install && make clean + + if [ -d ${apacheDir}/apr-${APR_VERSION} ];then + rm -rf ${apacheDir}/apr-${APR_VERSION} + fi + + if [ -d ${apacheDir}/apr-util-${APR_UTIL_VERSION} ];then + rm -rf ${apacheDir}/apr-util-${APR_UTIL_VERSION} + fi + + echo 'installation of apache completed' } From a9736965018068b21bf865116d06179bf71453c5 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 16:30:49 +0800 Subject: [PATCH 07/76] Update install.sh --- plugins/apache/versions/2.4/install.sh | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/plugins/apache/versions/2.4/install.sh b/plugins/apache/versions/2.4/install.sh index b584de87c..adaca358d 100644 --- a/plugins/apache/versions/2.4/install.sh +++ b/plugins/apache/versions/2.4/install.sh @@ -85,8 +85,6 @@ Install_App() # 安装 APR-util if [ ! -d ${serverPath}/apache/apr-util ];then cd ${apacheDir} && tar -jxf apr-util-${APR_UTIL_VERSION}.tar.bz2 - echo "${apacheDir} && tar -jxf apr-util-${APR_UTIL_VERSION}.tar.bz2" - echo "cd ${apacheDir}/apr-util-${APR_UTIL_VERSION} && ./configure --prefix=${serverPath}/apache/apr-util --with-apr=${serverPath}/apache/apr" cd ${apacheDir}/apr-util-${APR_UTIL_VERSION} && ./configure --prefix=${serverPath}/apache/apr-util --with-apr=${serverPath}/apache/apr if [ "$?" == "0" ];then make -j${cpuCore} && make install @@ -111,25 +109,14 @@ Install_App() # 检查 APR 和 APR-util 可执行文件 - APR_CONFIG=$(find ${serverPath}/apache/apr -name "apr-config" | head -1) - APU_CONFIG=$(find ${serverPath}/apache/apr-util -name "apu-config" | head -1) + APR_CONFIG=$(find ${serverPath}/apache/apr -name "apr-1-config" | head -1) + APU_CONFIG=$(find ${serverPath}/apache/apr-util -name "apu-1-config" | head -1) - if [ -z "$APR_CONFIG" ];then - echo "APR config not found" - exit 1 - fi - - if [ -z "$APU_CONFIG" ];then - echo "APR-util config not found" - exit 1 - fi - - echo "Using APR config: $APR_CONFIG" - echo "Using APR-util config: $APU_CONFIG" - - OPTIONS="${OPTIONS}--with-apr=$APR_CONFIG" + OPTIONS="${OPTIONS} --with-apr=$APR_CONFIG" OPTIONS="${OPTIONS} --with-apr-util=$APU_CONFIG" + echo "cd ${apacheDir}/httpd-${VERSION} && ./configure --prefix=$serverPath/apache $OPTIONS" + cd ${apacheDir}/httpd-${VERSION} && ./configure \ --prefix=$serverPath/apache \ $OPTIONS From 5b8148b83dd3525dc839595b79130171b86d5c3f Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 16:32:04 +0800 Subject: [PATCH 08/76] Update install.sh --- plugins/apache/versions/2.4/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/apache/versions/2.4/install.sh b/plugins/apache/versions/2.4/install.sh index adaca358d..332b29313 100644 --- a/plugins/apache/versions/2.4/install.sh +++ b/plugins/apache/versions/2.4/install.sh @@ -118,7 +118,7 @@ Install_App() echo "cd ${apacheDir}/httpd-${VERSION} && ./configure --prefix=$serverPath/apache $OPTIONS" cd ${apacheDir}/httpd-${VERSION} && ./configure \ - --prefix=$serverPath/apache \ + --prefix=$serverPath/apache/httpd \ $OPTIONS make -j${cpuCore} && make install && make clean From 30b106c5c24d8fc3d228d463b3ba6f8452e8b4ad Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 16:32:44 +0800 Subject: [PATCH 09/76] Update install.sh --- plugins/apache/versions/2.4/install.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/apache/versions/2.4/install.sh b/plugins/apache/versions/2.4/install.sh index 332b29313..2d3ec2737 100644 --- a/plugins/apache/versions/2.4/install.sh +++ b/plugins/apache/versions/2.4/install.sh @@ -115,8 +115,7 @@ Install_App() OPTIONS="${OPTIONS} --with-apr=$APR_CONFIG" OPTIONS="${OPTIONS} --with-apr-util=$APU_CONFIG" - echo "cd ${apacheDir}/httpd-${VERSION} && ./configure --prefix=$serverPath/apache $OPTIONS" - + # echo "cd ${apacheDir}/httpd-${VERSION} && ./configure --prefix=$serverPath/apache $OPTIONS" cd ${apacheDir}/httpd-${VERSION} && ./configure \ --prefix=$serverPath/apache/httpd \ $OPTIONS @@ -132,6 +131,9 @@ Install_App() rm -rf ${apacheDir}/apr-util-${APR_UTIL_VERSION} fi + if [ -d ${apacheDir}/httpd-${APR_UTIL_VERSION} ];then + rm -rf ${apacheDir}/httpd-${APR_UTIL_VERSION} + fi echo 'installation of apache completed' } From d3a7f7a7326b1d9973d3c1491c9d926d723970f1 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 16:34:01 +0800 Subject: [PATCH 10/76] Update install.sh --- plugins/apache/versions/2.4/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/apache/versions/2.4/install.sh b/plugins/apache/versions/2.4/install.sh index 2d3ec2737..081d82532 100644 --- a/plugins/apache/versions/2.4/install.sh +++ b/plugins/apache/versions/2.4/install.sh @@ -88,7 +88,7 @@ Install_App() cd ${apacheDir}/apr-util-${APR_UTIL_VERSION} && ./configure --prefix=${serverPath}/apache/apr-util --with-apr=${serverPath}/apache/apr if [ "$?" == "0" ];then make -j${cpuCore} && make install - if [ ! -f ${serverPath}/apache/apr-util/bin/apu-config ];then + if [ ! -f ${serverPath}/apache/apr-util/bin/apu-1-config ];then echo "APR-util installation failed: apu-config not found" find ${serverPath}/apache/apr-util -name "apu-config" exit 1 From ecab1a45b90484fa3f90482e26b353986747ff79 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 16:46:12 +0800 Subject: [PATCH 11/76] up --- plugins/apache/conf/httpd.conf | 109 ------------------------- plugins/apache/index.py | 41 ++-------- plugins/apache/versions/2.4/install.sh | 6 +- 3 files changed, 8 insertions(+), 148 deletions(-) diff --git a/plugins/apache/conf/httpd.conf b/plugins/apache/conf/httpd.conf index 250e92faf..e69de29bb 100644 --- a/plugins/apache/conf/httpd.conf +++ b/plugins/apache/conf/httpd.conf @@ -1,109 +0,0 @@ -user {$OS_USER} {$OS_USER_GROUP}; -worker_processes auto; -worker_cpu_affinity auto; -error_log {$SERVER_PATH}/openresty/nginx/logs/error.log crit; -pid {$SERVER_PATH}/openresty/nginx/logs/nginx.pid; - -worker_rlimit_nofile 65535; -pcre_jit on; - -events -{ - use {$EVENT_MODEL}; - worker_connections 51200; - multi_accept on; - - # file/video close the mutex lock when under high load - # accept_mutex off; -} - -http -{ - include mime.types; - - include {$SERVER_PATH}/web_conf/nginx/lua/lua.conf; - #include proxy.conf; - - default_type application/octet-stream; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for" "$request_time"'; - - server_names_hash_bucket_size 32; - client_header_buffer_size 32k; - large_client_header_buffers 4 32k; - client_body_buffer_size 128k; - client_max_body_size 20m; - - # video big file opt - aio threads; - directio 4m; - output_buffers 16 512k; - sendfile on; - tcp_nopush on; - tcp_nodelay on; - - keepalive_timeout 60; - - fastcgi_connect_timeout 60; - fastcgi_send_timeout 60; - fastcgi_read_timeout 60; - fastcgi_buffer_size 64k; - fastcgi_buffers 4 64k; - fastcgi_busy_buffers_size 128k; - fastcgi_temp_file_write_size 256k; - fastcgi_intercept_errors on; - - zstd off; - zstd_comp_level 6; - zstd_min_length 256; - zstd_types text/plain text/css text/xml text/javascript text/cache-manifest text/x-component text/vtt application/javascript application/json application/ld+json application/xml application/xhtml+xml application/rss+xml application/atom+xml application/manifest+json application/x-web-app-manifest+json application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/wasm font/opentype image/svg+xml image/bmp; - - brotli off; - brotli_min_length 256; - brotli_buffers 32 8k; - brotli_comp_level 4; - brotli_window 16m; - brotli_static on; - brotli_types text/plain text/css text/xml text/javascript text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml application/atom+xml application/vnd.ms-fontobject application/x-font-ttf application/x-font-opentype application/x-font-truetype font/tpl font/opentype font/otf font/ttf image/svg+xml image/x-icon image/vnd.microsoft.icon application/wasm application/manifest+json; - - gzip on; - gzip_min_length 1k; - gzip_buffers 4 16k; - gzip_http_version 1.1; - gzip_comp_level 9; - gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml; - gzip_vary on; - gzip_proxied expired no-cache no-store private auth; - gzip_disable "MSIE [1-6]\."; - - - limit_conn_zone $binary_remote_addr zone=perip:10m; - limit_conn_zone $server_name zone=perserver:10m; - - # CACEH_BEGIN - proxy_buffering on; - proxy_buffer_size 1024k; - proxy_buffers 16 1024k; - proxy_busy_buffers_size 2048k; - proxy_temp_file_write_size 2048k; - proxy_cache_path {$SERVER_PATH}/openresty/nginx/proxy_cache_temp levels=1:2 keys_zone=mw_cache:512m inactive=5m max_size=2g use_temp_path=off; - #proxy timeout - proxy_connect_timeout 3s; - proxy_read_timeout 5s; - proxy_send_timeout 5s; - - fastcgi_cache_key "$scheme$request_method$host$request_uri"; - fastcgi_cache_path {$SERVER_PATH}/openresty/nginx/fastcgi_cache_temp levels=1:2 keys_zone=mw_cache_fcgi:100m inactive=60m max_size=5g; - fastcgi_cache_use_stale error timeout invalid_header http_500; - fastcgi_ignore_headers Cache-Control Expires Set-Cookie; - # CACEH_END - - server_tokens off; - access_log /dev/null; - more_set_headers "Server: mdserver-web"; - - include {$SERVER_PATH}/web_conf/nginx/vhost/*.conf; -} - diff --git a/plugins/apache/index.py b/plugins/apache/index.py index a185e2906..c010fba3d 100755 --- a/plugins/apache/index.py +++ b/plugins/apache/index.py @@ -70,7 +70,7 @@ def checkArgs(data, ck=[]): def clearTemp(): - path_bin = getServerDir() + "/nginx" + path_bin = getServerDir() + "/apache/httpd" mw.execShell('rm -rf ' + path_bin + '/client_body_temp') mw.execShell('rm -rf ' + path_bin + '/fastcgi_temp') mw.execShell('rm -rf ' + path_bin + '/proxy_temp') @@ -79,33 +79,24 @@ def clearTemp(): def getConf(): - path = getServerDir() + "/nginx/conf/nginx.conf" + path = getServerDir() + "/httpd/conf/httpd.conf" return path def getConfTpl(): - path = getPluginDir() + '/conf/nginx.conf' + path = getPluginDir() + '/conf/httpd.conf' return path def getOs(): data = {} data['os'] = mw.getOs() - ng_exe_bin = getServerDir() + "/nginx/sbin/nginx" - - # if mw.isAppleSystem(): - # data['auth'] = True - # return mw.getJson(data) - - if checkAuthEq(ng_exe_bin, 'root'): - data['auth'] = True - else: - data['auth'] = False + data['auth'] = True return mw.getJson(data) def getInitDTpl(): - path = getPluginDir() + "/init.d/nginx.tpl" + path = getPluginDir() + "/init.d/httpd.tpl" return path @@ -207,28 +198,6 @@ def initDreplace(): # config replace confReplace() - # give nginx root permission - # ng_exe_bin = getServerDir() + "/nginx/sbin/nginx" - # if not checkAuthEq(ng_exe_bin, 'root'): - # user = 'www' - # user_group = 'www' - # current_os = mw.getOs() - # if current_os == 'darwin': - # user = 'root' - # user_group = 'staff' - # args = getArgs() - # if not 'pwd' in args: - # print("权限不足,需要认证启动!") - # exit(0) - - sudoPwd = args['pwd'] - cmd_own = 'chown -R ' + user+':' + user_group + ' ' + ng_exe_bin - mw.execShell('echo %s|sudo -S %s' % (sudoPwd, cmd_own)) - cmd_mod = 'chmod 755 ' + ng_exe_bin - mw.execShell('echo %s|sudo -S %s' % (sudoPwd, cmd_mod)) - cmd_s = 'chmod u+s ' + ng_exe_bin - mw.execShell('echo %s|sudo -S %s' % (sudoPwd, cmd_s)) - # systemd # /usr/lib/systemd/system systemDir = mw.systemdCfgDir() diff --git a/plugins/apache/versions/2.4/install.sh b/plugins/apache/versions/2.4/install.sh index 081d82532..02272652d 100644 --- a/plugins/apache/versions/2.4/install.sh +++ b/plugins/apache/versions/2.4/install.sh @@ -70,9 +70,9 @@ Install_App() if [ ! -d ${serverPath}/apache/apr ];then cd ${apacheDir} && tar -jxf apr-${APR_VERSION}.tar.bz2 cd ${apacheDir}/apr-${APR_VERSION} && ./configure --prefix=${serverPath}/apache/apr + make -j${cpuCore} && make install if [ "$?" == "0" ];then - make -j${cpuCore} && make install - if [ ! -f ${serverPath}/apache/apr/bin/apr-config ];then + if [ ! -f ${serverPath}/apache/apr/bin/apr-1-config ];then echo "APR installation failed: apr-config not found" exit 1 fi @@ -86,8 +86,8 @@ Install_App() if [ ! -d ${serverPath}/apache/apr-util ];then cd ${apacheDir} && tar -jxf apr-util-${APR_UTIL_VERSION}.tar.bz2 cd ${apacheDir}/apr-util-${APR_UTIL_VERSION} && ./configure --prefix=${serverPath}/apache/apr-util --with-apr=${serverPath}/apache/apr + make -j${cpuCore} && make install if [ "$?" == "0" ];then - make -j${cpuCore} && make install if [ ! -f ${serverPath}/apache/apr-util/bin/apu-1-config ];then echo "APR-util installation failed: apu-config not found" find ${serverPath}/apache/apr-util -name "apu-config" From b85bb698d0206f35b5ece9e99515c6a251ad2f95 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 16:56:03 +0800 Subject: [PATCH 12/76] up --- plugins/apache/init.d/httpd.tpl | 126 ++++++------------------- plugins/apache/js/httpd.js | 18 ++-- plugins/apache/versions/2.4/install.sh | 59 ++++++++---- test_apache_install.sh | 9 ++ 4 files changed, 85 insertions(+), 127 deletions(-) create mode 100644 test_apache_install.sh diff --git a/plugins/apache/init.d/httpd.tpl b/plugins/apache/init.d/httpd.tpl index d773f931a..e248690e5 100644 --- a/plugins/apache/init.d/httpd.tpl +++ b/plugins/apache/init.d/httpd.tpl @@ -1,118 +1,48 @@ -#! /bin/sh -# chkconfig: 2345 55 25 -# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and -# run 'update-rc.d -f nginx defaults', or use the appropriate command on your -# distro. For CentOS/Redhat run: 'chkconfig --add openresty' +#!/bin/bash +# chkconfig: 345 85 15 +# description: Apache Server ### BEGIN INIT INFO -# Provides: nginx -# Required-Start: $all -# Required-Stop: $all +# Provides: apache +# Required-Start: $network +# Required-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -# Short-Description: starts the nginx web server -# Description: starts nginx using start-stop-daemon +# Description: Apache Server ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/homebrew/bin -NAME=nginx -NGINX_BIN={$SERVER_PATH}/openresty/bin/openresty -CONFIGFILE={$SERVER_PATH}/openresty/nginx/conf/$NAME.conf -PIDFILE={$SERVER_PATH}/openresty/nginx/logs/$NAME.pid +NAME=apache +# Apache 可执行文件的路径 +DAEMON={$SERVER_PATH}/httpd/bin/httpd +# 进程的 PID 文件路径 +PIDFILE={$SERVER_PATH}/httpd/logs/httpd.pid +# 根据传入的参数执行不同操作 case "$1" in start) - echo -n "Starting $NAME... " - if [ -f $PIDFILE ];then - mPID=`cat $PIDFILE` - isStart=`ps ax | awk '{ print $1 }' | grep -e "^${mPID}$"` - if [ "$isStart" != '' ];then - echo "$NAME (pid `pidof $NAME`) already running." - exit 1 - fi - fi - - $NGINX_BIN -c $CONFIGFILE - - if [ "$?" != 0 ] ; then - echo " failed" - exit 1 - else - echo " done" - fi + echo "Starting Apache..." + $DAEMON -k start ;; - stop) - echo -n "Stoping $NAME... " - if [ -f $PIDFILE ];then - mPID=`cat $PIDFILE` - isStart=`ps ax | awk '{ print $1 }' | grep -e "^${mPID}$"` - if [ "$isStart" = '' ];then - echo "$NAME is not running." - exit 1 - fi - else - echo "$NAME is not running." - exit 1 - fi - $NGINX_BIN -s stop - - if [ "$?" != 0 ] ; then - echo " failed. Use force-quit" - exit 1 - else - echo " done" - fi - ;; - - status) - if [ -f $PIDFILE ];then - mPID=`cat $PIDFILE` - isStart=`ps ax | awk '{ print $1 }' | grep -e "^${mPID}$"` - if [ "$isStart" != '' ];then - echo "$NAME (pid `pidof $NAME`) already running." - exit 1 - else - echo "$NAME is stopped" - exit 0 - fi - else - echo "$NAME is stopped" - exit 0 - fi + echo "Stopping Apache..." + $DAEMON -k stop ;; restart) - $0 stop - sleep 1 - $0 start + echo "Restarting Apache..." + $DAEMON -k restart ;; - - reload) - echo -n "Reload service $NAME... " - if [ -f $PIDFILE ];then - mPID=`cat $PIDFILE` - isStart=`ps ax | awk '{ print $1 }' | grep -e "^${mPID}$"` - if [ "$isStart" != '' ];then - $NGINX_BIN -s reload - echo " done" - else - echo "$NAME is not running, can't reload." - exit 1 - fi - else - echo "$NAME is not running, can't reload." - exit 1 - fi + status) + if [ -f $PIDFILE ]; then + echo "Apache is running." + else + echo "Apache is not running." + fi ;; - - configtest) - echo -n "Test $NAME configure files... " - $NGINX_BIN -t - ;; - *) - echo "Usage: $0 {start|stop|restart|reload|status|configtest}" + echo "Usage: $0 {start|stop|restart|status}" exit 1 - ;; esac + +exit 0 \ No newline at end of file diff --git a/plugins/apache/js/httpd.js b/plugins/apache/js/httpd.js index 13e318797..08fda3b5e 100755 --- a/plugins/apache/js/httpd.js +++ b/plugins/apache/js/httpd.js @@ -1,6 +1,6 @@ -function orPost(method, args, callback){ +function httpPost(method, args, callback){ var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); - $.post('/plugins/run', {name:'openresty', func:method, args:JSON.stringify(args)}, function(data) { + $.post('/plugins/run', {name:'apache', func:method, args:JSON.stringify(args)}, function(data) { layer.close(loadT); if (!data.status){ layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']}); @@ -21,7 +21,7 @@ function orPluginService(_name, version){ version = ''; } - orPost('status', data, function(data){ + httpPost('status', data, function(data){ if (data.data == 'start'){ orPluginSetService(_name, true, version); } else { @@ -59,7 +59,7 @@ function orPluginOpService(a, b, v,request_callback) { case "reload":d = '重载';break; } layer.confirm( msgTpl('您真的要{1}{2}{3}服务吗?', [d,a,v]), {icon:3,closeBtn: 2}, function() { - orPost('get_os',{},function(data){ + httpPost('get_os',{},function(data){ var rdata = $.parseJSON(data.data); if (!rdata['auth']){ layer.prompt({title: '检查到权限不足,需要输入密码!', formType: 1},function(pwd, index){ @@ -113,7 +113,7 @@ function orPluginOpServiceOp(a,b,c,d,a,v,request_callback){ //查看Nginx负载状态 function getOpStatus() { var loadT = layer.msg('正在处理,请稍后...', { icon: 16, time: 0, shade: 0.3 }); - $.post('/plugins/run', {name:'openresty', func:'run_info'}, function(data) { + $.post('/plugins/run', {name:'apache', func:'run_info'}, function(data) { layer.close(loadT); try { var rdata = $.parseJSON(data.data); @@ -140,7 +140,7 @@ function getOpStatus() { function setOpCfg(){ - orPost('get_cfg', {}, function(data){ + httpPost('get_cfg', {}, function(data){ var rdata = $.parseJSON(data.data); var rdata = rdata.data; // console.log(rdata); @@ -196,7 +196,7 @@ function submitConf() { }; // console.log(data); - orPost('set_cfg', data, function(rdata){ + httpPost('set_cfg', data, function(rdata){ var rdata = $.parseJSON(rdata.data); // console.log(rdata); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); @@ -212,14 +212,14 @@ function otherFunc(){ } function cronAddCheck(){ - orPost('cron_add_check', {}, function(data){ + httpPost('cron_add_check', {}, function(data){ var rdata = $.parseJSON(data.data); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); }); } function cronDelCheck(){ - orPost('cron_del_check', {}, function(data){ + httpPost('cron_del_check', {}, function(data){ var rdata = $.parseJSON(data.data); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); }); diff --git a/plugins/apache/versions/2.4/install.sh b/plugins/apache/versions/2.4/install.sh index 02272652d..ddd67ae91 100644 --- a/plugins/apache/versions/2.4/install.sh +++ b/plugins/apache/versions/2.4/install.sh @@ -72,14 +72,17 @@ Install_App() cd ${apacheDir}/apr-${APR_VERSION} && ./configure --prefix=${serverPath}/apache/apr make -j${cpuCore} && make install if [ "$?" == "0" ];then - if [ ! -f ${serverPath}/apache/apr/bin/apr-1-config ];then - echo "APR installation failed: apr-config not found" - exit 1 - fi - else - echo "APR configure failed" - exit 1 - fi + # 检查 APR 配置文件 + APR_CONFIG=$(find ${serverPath}/apache/apr -name "apr-*config" | head -1) + if [ -z "$APR_CONFIG" ];then + echo "APR installation failed: apr-config not found" + exit 1 + fi + echo "APR installed successfully: $APR_CONFIG" + else + echo "APR configure failed" + exit 1 + fi fi # 安装 APR-util @@ -88,15 +91,18 @@ Install_App() cd ${apacheDir}/apr-util-${APR_UTIL_VERSION} && ./configure --prefix=${serverPath}/apache/apr-util --with-apr=${serverPath}/apache/apr make -j${cpuCore} && make install if [ "$?" == "0" ];then - if [ ! -f ${serverPath}/apache/apr-util/bin/apu-1-config ];then - echo "APR-util installation failed: apu-config not found" - find ${serverPath}/apache/apr-util -name "apu-config" - exit 1 - fi - else - echo "APR-util configure failed" - exit 1 - fi + # 检查 APR-util 配置文件 + APU_CONFIG=$(find ${serverPath}/apache/apr-util -name "apu-*config" | head -1) + if [ -z "$APU_CONFIG" ];then + echo "APR-util installation failed: apu-config not found" + find ${serverPath}/apache/apr-util -name "apu-*config" + exit 1 + fi + echo "APR-util installed successfully: $APU_CONFIG" + else + echo "APR-util configure failed" + exit 1 + fi fi if [ ! -f ${apacheDir}/httpd-${VERSION}.tar.bz2 ];then @@ -109,15 +115,28 @@ Install_App() # 检查 APR 和 APR-util 可执行文件 - APR_CONFIG=$(find ${serverPath}/apache/apr -name "apr-1-config" | head -1) - APU_CONFIG=$(find ${serverPath}/apache/apr-util -name "apu-1-config" | head -1) + APR_CONFIG=$(find ${serverPath}/apache/apr -name "apr-*config" | head -1) + APU_CONFIG=$(find ${serverPath}/apache/apr-util -name "apu-*config" | head -1) + + if [ -z "$APR_CONFIG" ];then + echo "APR config not found" + exit 1 + fi + + if [ -z "$APU_CONFIG" ];then + echo "APR-util config not found" + exit 1 + fi + +echo "Using APR config: $APR_CONFIG" +echo "Using APR-util config: $APU_CONFIG" OPTIONS="${OPTIONS} --with-apr=$APR_CONFIG" OPTIONS="${OPTIONS} --with-apr-util=$APU_CONFIG" # echo "cd ${apacheDir}/httpd-${VERSION} && ./configure --prefix=$serverPath/apache $OPTIONS" cd ${apacheDir}/httpd-${VERSION} && ./configure \ - --prefix=$serverPath/apache/httpd \ + --prefix=$serverPath/apache \ $OPTIONS make -j${cpuCore} && make install && make clean diff --git a/test_apache_install.sh b/test_apache_install.sh new file mode 100644 index 000000000..ece0710d6 --- /dev/null +++ b/test_apache_install.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# 测试 Apache 安装脚本 +cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/apache/versions/2.4 +echo "Running Apache install script..." +# 直接运行脚本,不使用 trae-sandbox +./install.sh upgrade + +echo "Installation completed with exit code: $?" From be6e0341533f704bcb4e525ac8465fdd8afe08a2 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 16:57:04 +0800 Subject: [PATCH 13/76] Update install.sh --- plugins/apache/versions/2.4/install.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/apache/versions/2.4/install.sh b/plugins/apache/versions/2.4/install.sh index ddd67ae91..d2148932d 100644 --- a/plugins/apache/versions/2.4/install.sh +++ b/plugins/apache/versions/2.4/install.sh @@ -128,15 +128,12 @@ Install_App() exit 1 fi -echo "Using APR config: $APR_CONFIG" -echo "Using APR-util config: $APU_CONFIG" - OPTIONS="${OPTIONS} --with-apr=$APR_CONFIG" OPTIONS="${OPTIONS} --with-apr-util=$APU_CONFIG" # echo "cd ${apacheDir}/httpd-${VERSION} && ./configure --prefix=$serverPath/apache $OPTIONS" cd ${apacheDir}/httpd-${VERSION} && ./configure \ - --prefix=$serverPath/apache \ + --prefix=$serverPath/apache/httpd \ $OPTIONS make -j${cpuCore} && make install && make clean From 584ac773b31461b3808ee3a4ab533b786b0c2910 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 17:01:44 +0800 Subject: [PATCH 14/76] Update install.sh --- plugins/apache/install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/apache/install.sh b/plugins/apache/install.sh index 76ebcd0f4..9a3105d3f 100755 --- a/plugins/apache/install.sh +++ b/plugins/apache/install.sh @@ -13,7 +13,8 @@ export PATH # apt install ncat -y # nc -u -v www.xx.com 443 -# cd /www/server/mdserver-web && python3 plugins/openresty/index.py run_info +# cd /www/server/mdserver-web && python3 plugins/apache/index.py run_info +# cd /www/server/mdserver-web && python3 plugins/apache/index.py run_info curPath=`pwd` rootPath=$(dirname "$curPath") From 5c53bb38533cc15a0ea444365af264003ec2d9ca Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 19:10:59 +0800 Subject: [PATCH 15/76] up --- plugins/apache/init.d/httpd.tpl | 5 ++--- plugins/apache/install.sh | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/apache/init.d/httpd.tpl b/plugins/apache/init.d/httpd.tpl index e248690e5..232843809 100644 --- a/plugins/apache/init.d/httpd.tpl +++ b/plugins/apache/init.d/httpd.tpl @@ -13,11 +13,10 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/homebrew/bin -NAME=apache # Apache 可执行文件的路径 -DAEMON={$SERVER_PATH}/httpd/bin/httpd +DAEMON={$SERVER_PATH}/apache/httpd/bin/httpd # 进程的 PID 文件路径 -PIDFILE={$SERVER_PATH}/httpd/logs/httpd.pid +PIDFILE={$SERVER_PATH}/apache/httpd/logs/httpd.pid # 根据传入的参数执行不同操作 case "$1" in diff --git a/plugins/apache/install.sh b/plugins/apache/install.sh index 9a3105d3f..461e93fe0 100755 --- a/plugins/apache/install.sh +++ b/plugins/apache/install.sh @@ -13,7 +13,7 @@ export PATH # apt install ncat -y # nc -u -v www.xx.com 443 -# cd /www/server/mdserver-web && python3 plugins/apache/index.py run_info +# cd /www/server/mdserver-web && python3 plugins/apache/index.py start # cd /www/server/mdserver-web && python3 plugins/apache/index.py run_info curPath=`pwd` From 320001b3a35e2b924d77432d6dc36791cd83e7d7 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 20:14:46 +0800 Subject: [PATCH 16/76] Update httpd.service.tpl --- plugins/apache/init.d/httpd.service.tpl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/apache/init.d/httpd.service.tpl b/plugins/apache/init.d/httpd.service.tpl index ac52989a0..eba026792 100644 --- a/plugins/apache/init.d/httpd.service.tpl +++ b/plugins/apache/init.d/httpd.service.tpl @@ -1,13 +1,16 @@ [Unit] -Description=OpenResty is a dynamic web platform based on NGINX and LuaJIT. +Description=Apache Web Server After=network.target [Service] -Type=forking -ExecStart={$SERVER_PATH}/apache/bin/httpd -c {$SERVER_PATH}/apache/nginx/conf/nginx.conf -ExecStop={$SERVER_PATH}/apache/bin/httpd -s stop -ExecReload={$SERVER_PATH}/apache/bin/httpd -s reload -KillMode=process +Type=forking +PIDFile={$SERVER_PATH}/apache/httpd/logs/httpd.pid +ExecStart={$SERVER_PATH}/apache/httpd/bin/apachectl start +ExecReload={$SERVER_PATH}/apache/httpd/bin/apachectl graceful +ExecStop={$SERVER_PATH}/apache/httpd/bin/apachectl stop +PrivateTmp=true +User=apache +Group=apache Restart=on-failure [Install] From b769b79b9a33be5269f0a1d782dfdc0d9cb68f19 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 20:23:44 +0800 Subject: [PATCH 17/76] update --- plugins/apache/index.html | 6 +++--- plugins/apache/index.py | 5 +++-- plugins/apache/install.sh | 1 + plugins/apache/js/httpd.js | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/apache/index.html b/plugins/apache/index.html index 153330175..62a7d71df 100755 --- a/plugins/apache/index.html +++ b/plugins/apache/index.html @@ -2,7 +2,7 @@
-

服务

+

服务

自启动

配置修改

负载状态

@@ -18,7 +18,7 @@
\ No newline at end of file diff --git a/plugins/apache/index.py b/plugins/apache/index.py index c010fba3d..7493175c8 100755 --- a/plugins/apache/index.py +++ b/plugins/apache/index.py @@ -213,8 +213,9 @@ def initDreplace(): def status(): - pid_file = getPidFile() - if not os.path.exists(pid_file): + cmd = "ps -ef|grep 'httpd/bin/httpd' |grep -v grep | grep -v python | awk '{print $2}'" + data = mw.execShell(cmd) + if data[0] == '': return 'stop' return 'start' diff --git a/plugins/apache/install.sh b/plugins/apache/install.sh index 461e93fe0..8df0bfec6 100755 --- a/plugins/apache/install.sh +++ b/plugins/apache/install.sh @@ -13,6 +13,7 @@ export PATH # apt install ncat -y # nc -u -v www.xx.com 443 +# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/apache && python3 plugins/apache/index.py start # cd /www/server/mdserver-web && python3 plugins/apache/index.py start # cd /www/server/mdserver-web && python3 plugins/apache/index.py run_info diff --git a/plugins/apache/js/httpd.js b/plugins/apache/js/httpd.js index 08fda3b5e..a6dbefba8 100755 --- a/plugins/apache/js/httpd.js +++ b/plugins/apache/js/httpd.js @@ -13,7 +13,7 @@ function httpPost(method, args, callback){ },'json'); } -function orPluginService(_name, version){ +function httpPluginService(_name, version){ var data = {name:_name, func:'status'} if ( typeof(version) != 'undefined' ){ data['version'] = version; From f7d7ee6b437358302166265394453b651d83a248 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 20:30:00 +0800 Subject: [PATCH 18/76] update --- plugins/apache/conf/httpd.conf | 506 +++++++++++++++++++++++++++++ plugins/apache/conf/httpd.conf.tpl | 506 +++++++++++++++++++++++++++++ 2 files changed, 1012 insertions(+) create mode 100644 plugins/apache/conf/httpd.conf.tpl diff --git a/plugins/apache/conf/httpd.conf b/plugins/apache/conf/httpd.conf index e69de29bb..41aff4bce 100644 --- a/plugins/apache/conf/httpd.conf +++ b/plugins/apache/conf/httpd.conf @@ -0,0 +1,506 @@ +# +# This is the main Apache HTTP server configuration file. It contains the +# configuration directives that give the server its instructions. +# See for detailed information. +# In particular, see +# +# for a discussion of each configuration directive. +# +# Do NOT simply read the instructions in here without understanding +# what they do. They're here only as hints or reminders. If you are unsure +# consult the online docs. You have been warned. +# +# Configuration and logfile names: If the filenames you specify for many +# of the server's control files begin with "/" (or "drive:/" for Win32), the +# server will use that explicit path. If the filenames do *not* begin +# with "/", the value of ServerRoot is prepended -- so "logs/access_log" +# with ServerRoot set to "/usr/local/apache2" will be interpreted by the +# server as "/usr/local/apache2/logs/access_log", whereas "/logs/access_log" +# will be interpreted as '/logs/access_log'. + +# +# ServerRoot: The top of the directory tree under which the server's +# configuration, error, and log files are kept. +# +# Do not add a slash at the end of the directory path. If you point +# ServerRoot at a non-local disk, be sure to specify a local disk on the +# Mutex directive, if file-based mutexes are used. If you wish to share the +# same ServerRoot for multiple httpd daemons, you will need to change at +# least PidFile. +# +ServerRoot "/Users/midoks/Desktop/mwdev/server/apache/httpd" + +# +# Mutex: Allows you to set the mutex mechanism and mutex file directory +# for individual mutexes, or change the global defaults +# +# Uncomment and change the directory if mutexes are file-based and the default +# mutex file directory is not on a local disk or is not appropriate for some +# other reason. +# +# Mutex default:logs + +# +# Listen: Allows you to bind Apache to specific IP addresses and/or +# ports, instead of the default. See also the +# directive. +# +# Change this to Listen on specific IP addresses as shown below to +# prevent Apache from glomming onto all bound IP addresses. +# +#Listen 12.34.56.78:80 +Listen 80 + +# +# Dynamic Shared Object (DSO) Support +# +# To be able to use the functionality of a module which was built as a DSO you +# have to place corresponding `LoadModule' lines at this location so the +# directives contained in it are actually available _before_ they are used. +# Statically compiled modules (those listed by `httpd -l') do not need +# to be loaded here. +# +# Example: +# LoadModule foo_module modules/mod_foo.so +# +LoadModule authn_file_module modules/mod_authn_file.so +#LoadModule authn_dbm_module modules/mod_authn_dbm.so +#LoadModule authn_anon_module modules/mod_authn_anon.so +#LoadModule authn_dbd_module modules/mod_authn_dbd.so +#LoadModule authn_socache_module modules/mod_authn_socache.so +LoadModule authn_core_module modules/mod_authn_core.so +LoadModule authz_host_module modules/mod_authz_host.so +LoadModule authz_groupfile_module modules/mod_authz_groupfile.so +LoadModule authz_user_module modules/mod_authz_user.so +#LoadModule authz_dbm_module modules/mod_authz_dbm.so +#LoadModule authz_owner_module modules/mod_authz_owner.so +#LoadModule authz_dbd_module modules/mod_authz_dbd.so +LoadModule authz_core_module modules/mod_authz_core.so +LoadModule access_compat_module modules/mod_access_compat.so +LoadModule auth_basic_module modules/mod_auth_basic.so +#LoadModule auth_form_module modules/mod_auth_form.so +#LoadModule auth_digest_module modules/mod_auth_digest.so +#LoadModule allowmethods_module modules/mod_allowmethods.so +#LoadModule file_cache_module modules/mod_file_cache.so +#LoadModule cache_module modules/mod_cache.so +#LoadModule cache_disk_module modules/mod_cache_disk.so +#LoadModule cache_socache_module modules/mod_cache_socache.so +#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so +#LoadModule socache_dbm_module modules/mod_socache_dbm.so +#LoadModule socache_memcache_module modules/mod_socache_memcache.so +#LoadModule socache_redis_module modules/mod_socache_redis.so +#LoadModule watchdog_module modules/mod_watchdog.so +#LoadModule macro_module modules/mod_macro.so +#LoadModule dbd_module modules/mod_dbd.so +#LoadModule dumpio_module modules/mod_dumpio.so +#LoadModule buffer_module modules/mod_buffer.so +#LoadModule ratelimit_module modules/mod_ratelimit.so +LoadModule reqtimeout_module modules/mod_reqtimeout.so +#LoadModule ext_filter_module modules/mod_ext_filter.so +#LoadModule request_module modules/mod_request.so +#LoadModule include_module modules/mod_include.so +LoadModule filter_module modules/mod_filter.so +#LoadModule substitute_module modules/mod_substitute.so +#LoadModule sed_module modules/mod_sed.so +#LoadModule brotli_module modules/mod_brotli.so +LoadModule mime_module modules/mod_mime.so +LoadModule log_config_module modules/mod_log_config.so +#LoadModule log_debug_module modules/mod_log_debug.so +#LoadModule logio_module modules/mod_logio.so +LoadModule env_module modules/mod_env.so +#LoadModule expires_module modules/mod_expires.so +LoadModule headers_module modules/mod_headers.so +#LoadModule unique_id_module modules/mod_unique_id.so +LoadModule setenvif_module modules/mod_setenvif.so +LoadModule version_module modules/mod_version.so +#LoadModule remoteip_module modules/mod_remoteip.so +#LoadModule proxy_module modules/mod_proxy.so +#LoadModule proxy_connect_module modules/mod_proxy_connect.so +#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so +#LoadModule proxy_http_module modules/mod_proxy_http.so +#LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so +#LoadModule proxy_scgi_module modules/mod_proxy_scgi.so +#LoadModule proxy_uwsgi_module modules/mod_proxy_uwsgi.so +#LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so +#LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so +#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so +#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so +#LoadModule proxy_express_module modules/mod_proxy_express.so +#LoadModule proxy_hcheck_module modules/mod_proxy_hcheck.so +#LoadModule session_module modules/mod_session.so +#LoadModule session_cookie_module modules/mod_session_cookie.so +#LoadModule session_dbd_module modules/mod_session_dbd.so +#LoadModule slotmem_shm_module modules/mod_slotmem_shm.so +#LoadModule ssl_module modules/mod_ssl.so +#LoadModule http2_module modules/mod_http2.so +#LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so +#LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so +#LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so +#LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so +LoadModule unixd_module modules/mod_unixd.so +#LoadModule dav_module modules/mod_dav.so +LoadModule status_module modules/mod_status.so +LoadModule autoindex_module modules/mod_autoindex.so +#LoadModule info_module modules/mod_info.so +#LoadModule cgid_module modules/mod_cgid.so +#LoadModule dav_fs_module modules/mod_dav_fs.so +#LoadModule vhost_alias_module modules/mod_vhost_alias.so +#LoadModule negotiation_module modules/mod_negotiation.so +LoadModule dir_module modules/mod_dir.so +#LoadModule actions_module modules/mod_actions.so +#LoadModule speling_module modules/mod_speling.so +#LoadModule userdir_module modules/mod_userdir.so +LoadModule alias_module modules/mod_alias.so +#LoadModule rewrite_module modules/mod_rewrite.so + + +# +# If you wish httpd to run as a different user or group, you must run +# httpd as root initially and it will switch. +# +# User/Group: The name (or #number) of the user/group to run httpd as. +# It is usually good practice to create a dedicated user and group for +# running httpd, as with most system services. +# +User daemon +Group daemon + + + +# 'Main' server configuration +# +# The directives in this section set up the values used by the 'main' +# server, which responds to any requests that aren't handled by a +# definition. These values also provide defaults for +# any containers you may define later in the file. +# +# All of these directives may appear inside containers, +# in which case these default settings will be overridden for the +# virtual host being defined. +# + +# +# ServerAdmin: Your address, where problems with the server should be +# e-mailed. This address appears on some server-generated pages, such +# as error documents. e.g. admin@your-domain.com +# +ServerAdmin you@example.com + +# +# ServerName gives the name and port that the server uses to identify itself. +# This can often be determined automatically, but we recommend you specify +# it explicitly to prevent problems during startup. +# +# If your host doesn't have a registered DNS name, enter its IP address here. +# +#ServerName www.example.com:80 + +# +# Deny access to the entirety of your server's filesystem. You must +# explicitly permit access to web content directories in other +# blocks below. +# + + AllowOverride none + Require all denied + + +# +# Note that from this point forward you must specifically allow +# particular features to be enabled - so if something's not working as +# you might expect, make sure that you have specifically enabled it +# below. +# + +# +# DocumentRoot: The directory out of which you will serve your +# documents. By default, all requests are taken from this directory, but +# symbolic links and aliases may be used to point to other locations. +# +DocumentRoot "/Users/midoks/Desktop/mwdev/server/apache/httpd/htdocs" + + # + # Possible values for the Options directive are "None", "All", + # or any combination of: + # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews + # + # Note that "MultiViews" must be named *explicitly* --- "Options All" + # doesn't give it to you. + # + # The Options directive is both complicated and important. Please see + # http://httpd.apache.org/docs/2.4/mod/core.html#options + # for more information. + # + Options Indexes FollowSymLinks + + # + # AllowOverride controls what directives may be placed in .htaccess files. + # It can be "All", "None", or any combination of the keywords: + # AllowOverride FileInfo AuthConfig Limit + # + AllowOverride None + + # + # Controls who can get stuff from this server. + # + Require all granted + + +# +# DirectoryIndex: sets the file that Apache will serve if a directory +# is requested. +# + + DirectoryIndex index.html + + +# +# The following lines prevent .htaccess and .htpasswd files from being +# viewed by Web clients. +# + + Require all denied + + +# +# ErrorLog: The location of the error log file. +# If you do not specify an ErrorLog directive within a +# container, error messages relating to that virtual host will be +# logged here. If you *do* define an error logfile for a +# container, that host's errors will be logged there and not here. +# +ErrorLog "logs/error_log" + +# +# LogLevel: Control the number of messages logged to the error_log. +# Possible values include: debug, info, notice, warn, error, crit, +# alert, emerg. +# +LogLevel warn + + + # + # The following directives define some format nicknames for use with + # a CustomLog directive (see below). + # + LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined + LogFormat "%h %l %u %t \"%r\" %>s %b" common + + + # You need to enable mod_logio.c to use %I and %O + LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio + + + # + # The location and format of the access logfile (Common Logfile Format). + # If you do not define any access logfiles within a + # container, they will be logged here. Contrariwise, if you *do* + # define per- access logfiles, transactions will be + # logged therein and *not* in this file. + # + CustomLog "logs/access_log" common + + # + # If you prefer a logfile with access, agent, and referer information + # (Combined Logfile Format) you can use the following directive. + # + #CustomLog "logs/access_log" combined + + + + # + # Redirect: Allows you to tell clients about documents that used to + # exist in your server's namespace, but do not anymore. The client + # will make a new request for the document at its new location. + # Example: + # Redirect permanent /foo http://www.example.com/bar + + # + # Alias: Maps web paths into filesystem paths and is used to + # access content that does not live under the DocumentRoot. + # Example: + # Alias /webpath /full/filesystem/path + # + # If you include a trailing / on /webpath then the server will + # require it to be present in the URL. You will also likely + # need to provide a section to allow access to + # the filesystem path. + + # + # ScriptAlias: This controls which directories contain server scripts. + # ScriptAliases are essentially the same as Aliases, except that + # documents in the target directory are treated as applications and + # run by the server when requested rather than as documents sent to the + # client. The same rules about trailing "/" apply to ScriptAlias + # directives as to Alias. + # + ScriptAlias /cgi-bin/ "/Users/midoks/Desktop/mwdev/server/apache/httpd/cgi-bin/" + + + + + # + # ScriptSock: On threaded servers, designate the path to the UNIX + # socket used to communicate with the CGI daemon of mod_cgid. + # + #Scriptsock cgisock + + +# +# "/Users/midoks/Desktop/mwdev/server/apache/httpd/cgi-bin" should be changed to whatever your ScriptAliased +# CGI directory exists, if you have that configured. +# + + AllowOverride None + Options None + Require all granted + + + + # + # Avoid passing HTTP_PROXY environment to CGI's on this or any proxied + # backend servers which have lingering "httpoxy" defects. + # 'Proxy' request header is undefined by the IETF, not listed by IANA + # + RequestHeader unset Proxy early + + + + # + # TypesConfig points to the file containing the list of mappings from + # filename extension to MIME-type. + # + TypesConfig conf/mime.types + + # + # AddType allows you to add to or override the MIME configuration + # file specified in TypesConfig for specific file types. + # + #AddType application/x-gzip .tgz + # + # AddEncoding allows you to have certain browsers uncompress + # information on the fly. Note: Not all browsers support this. + # + #AddEncoding x-compress .Z + #AddEncoding x-gzip .gz .tgz + # + # If the AddEncoding directives above are commented-out, then you + # probably should define those extensions to indicate media types: + # + AddType application/x-compress .Z + AddType application/x-gzip .gz .tgz + + # + # AddHandler allows you to map certain file extensions to "handlers": + # actions unrelated to filetype. These can be either built into the server + # or added with the Action directive (see below) + # + # To use CGI scripts outside of ScriptAliased directories: + # (You will also need to add "ExecCGI" to the "Options" directive.) + # + #AddHandler cgi-script .cgi + + # For type maps (negotiated resources): + #AddHandler type-map var + + # + # Filters allow you to process content before it is sent to the client. + # + # To parse .shtml files for server-side includes (SSI): + # (You will also need to add "Includes" to the "Options" directive.) + # + #AddType text/html .shtml + #AddOutputFilter INCLUDES .shtml + + +# +# The mod_mime_magic module allows the server to use various hints from the +# contents of the file itself to determine its type. The MIMEMagicFile +# directive tells the module where the hint definitions are located. +# +#MIMEMagicFile conf/magic + +# +# Customizable error responses come in three flavors: +# 1) plain text 2) local redirects 3) external redirects +# +# Some examples: +#ErrorDocument 500 "The server made a boo boo." +#ErrorDocument 404 /missing.html +#ErrorDocument 404 "/cgi-bin/missing_handler.pl" +#ErrorDocument 402 http://www.example.com/subscription_info.html +# + +# +# MaxRanges: Maximum number of Ranges in a request before +# returning the entire resource, or one of the special +# values 'default', 'none' or 'unlimited'. +# Default setting is to accept 200 Ranges. +#MaxRanges unlimited + +# +# EnableMMAP and EnableSendfile: On systems that support it, +# memory-mapping or the sendfile syscall may be used to deliver +# files. This usually improves server performance, but must +# be turned off when serving from networked-mounted +# filesystems or if support for these functions is otherwise +# broken on your system. +# Defaults: EnableMMAP On, EnableSendfile Off +# +#EnableMMAP off +#EnableSendfile on + +# Supplemental configuration +# +# The configuration files in the conf/extra/ directory can be +# included to add extra features or to modify the default configuration of +# the server, or you may simply copy their contents here and change as +# necessary. + +# Server-pool management (MPM specific) +#Include conf/extra/httpd-mpm.conf + +# Multi-language error messages +#Include conf/extra/httpd-multilang-errordoc.conf + +# Fancy directory listings +#Include conf/extra/httpd-autoindex.conf + +# Language settings +#Include conf/extra/httpd-languages.conf + +# User home directories +#Include conf/extra/httpd-userdir.conf + +# Real-time info on requests and configuration +#Include conf/extra/httpd-info.conf + +# Virtual hosts +#Include conf/extra/httpd-vhosts.conf + +# Local access to the Apache HTTP Server Manual +#Include conf/extra/httpd-manual.conf + +# Distributed authoring and versioning (WebDAV) +#Include conf/extra/httpd-dav.conf + +# Various default settings +#Include conf/extra/httpd-default.conf + +# Configure mod_proxy_html to understand HTML4/XHTML1 + +Include conf/extra/proxy-html.conf + + +# Secure (SSL/TLS) connections +#Include conf/extra/httpd-ssl.conf +# +# Note: The following must must be present to support +# starting without SSL on platforms with no /dev/random equivalent +# but a statically compiled-in mod_ssl. +# + +SSLRandomSeed startup builtin +SSLRandomSeed connect builtin + + diff --git a/plugins/apache/conf/httpd.conf.tpl b/plugins/apache/conf/httpd.conf.tpl new file mode 100644 index 000000000..41aff4bce --- /dev/null +++ b/plugins/apache/conf/httpd.conf.tpl @@ -0,0 +1,506 @@ +# +# This is the main Apache HTTP server configuration file. It contains the +# configuration directives that give the server its instructions. +# See for detailed information. +# In particular, see +# +# for a discussion of each configuration directive. +# +# Do NOT simply read the instructions in here without understanding +# what they do. They're here only as hints or reminders. If you are unsure +# consult the online docs. You have been warned. +# +# Configuration and logfile names: If the filenames you specify for many +# of the server's control files begin with "/" (or "drive:/" for Win32), the +# server will use that explicit path. If the filenames do *not* begin +# with "/", the value of ServerRoot is prepended -- so "logs/access_log" +# with ServerRoot set to "/usr/local/apache2" will be interpreted by the +# server as "/usr/local/apache2/logs/access_log", whereas "/logs/access_log" +# will be interpreted as '/logs/access_log'. + +# +# ServerRoot: The top of the directory tree under which the server's +# configuration, error, and log files are kept. +# +# Do not add a slash at the end of the directory path. If you point +# ServerRoot at a non-local disk, be sure to specify a local disk on the +# Mutex directive, if file-based mutexes are used. If you wish to share the +# same ServerRoot for multiple httpd daemons, you will need to change at +# least PidFile. +# +ServerRoot "/Users/midoks/Desktop/mwdev/server/apache/httpd" + +# +# Mutex: Allows you to set the mutex mechanism and mutex file directory +# for individual mutexes, or change the global defaults +# +# Uncomment and change the directory if mutexes are file-based and the default +# mutex file directory is not on a local disk or is not appropriate for some +# other reason. +# +# Mutex default:logs + +# +# Listen: Allows you to bind Apache to specific IP addresses and/or +# ports, instead of the default. See also the +# directive. +# +# Change this to Listen on specific IP addresses as shown below to +# prevent Apache from glomming onto all bound IP addresses. +# +#Listen 12.34.56.78:80 +Listen 80 + +# +# Dynamic Shared Object (DSO) Support +# +# To be able to use the functionality of a module which was built as a DSO you +# have to place corresponding `LoadModule' lines at this location so the +# directives contained in it are actually available _before_ they are used. +# Statically compiled modules (those listed by `httpd -l') do not need +# to be loaded here. +# +# Example: +# LoadModule foo_module modules/mod_foo.so +# +LoadModule authn_file_module modules/mod_authn_file.so +#LoadModule authn_dbm_module modules/mod_authn_dbm.so +#LoadModule authn_anon_module modules/mod_authn_anon.so +#LoadModule authn_dbd_module modules/mod_authn_dbd.so +#LoadModule authn_socache_module modules/mod_authn_socache.so +LoadModule authn_core_module modules/mod_authn_core.so +LoadModule authz_host_module modules/mod_authz_host.so +LoadModule authz_groupfile_module modules/mod_authz_groupfile.so +LoadModule authz_user_module modules/mod_authz_user.so +#LoadModule authz_dbm_module modules/mod_authz_dbm.so +#LoadModule authz_owner_module modules/mod_authz_owner.so +#LoadModule authz_dbd_module modules/mod_authz_dbd.so +LoadModule authz_core_module modules/mod_authz_core.so +LoadModule access_compat_module modules/mod_access_compat.so +LoadModule auth_basic_module modules/mod_auth_basic.so +#LoadModule auth_form_module modules/mod_auth_form.so +#LoadModule auth_digest_module modules/mod_auth_digest.so +#LoadModule allowmethods_module modules/mod_allowmethods.so +#LoadModule file_cache_module modules/mod_file_cache.so +#LoadModule cache_module modules/mod_cache.so +#LoadModule cache_disk_module modules/mod_cache_disk.so +#LoadModule cache_socache_module modules/mod_cache_socache.so +#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so +#LoadModule socache_dbm_module modules/mod_socache_dbm.so +#LoadModule socache_memcache_module modules/mod_socache_memcache.so +#LoadModule socache_redis_module modules/mod_socache_redis.so +#LoadModule watchdog_module modules/mod_watchdog.so +#LoadModule macro_module modules/mod_macro.so +#LoadModule dbd_module modules/mod_dbd.so +#LoadModule dumpio_module modules/mod_dumpio.so +#LoadModule buffer_module modules/mod_buffer.so +#LoadModule ratelimit_module modules/mod_ratelimit.so +LoadModule reqtimeout_module modules/mod_reqtimeout.so +#LoadModule ext_filter_module modules/mod_ext_filter.so +#LoadModule request_module modules/mod_request.so +#LoadModule include_module modules/mod_include.so +LoadModule filter_module modules/mod_filter.so +#LoadModule substitute_module modules/mod_substitute.so +#LoadModule sed_module modules/mod_sed.so +#LoadModule brotli_module modules/mod_brotli.so +LoadModule mime_module modules/mod_mime.so +LoadModule log_config_module modules/mod_log_config.so +#LoadModule log_debug_module modules/mod_log_debug.so +#LoadModule logio_module modules/mod_logio.so +LoadModule env_module modules/mod_env.so +#LoadModule expires_module modules/mod_expires.so +LoadModule headers_module modules/mod_headers.so +#LoadModule unique_id_module modules/mod_unique_id.so +LoadModule setenvif_module modules/mod_setenvif.so +LoadModule version_module modules/mod_version.so +#LoadModule remoteip_module modules/mod_remoteip.so +#LoadModule proxy_module modules/mod_proxy.so +#LoadModule proxy_connect_module modules/mod_proxy_connect.so +#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so +#LoadModule proxy_http_module modules/mod_proxy_http.so +#LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so +#LoadModule proxy_scgi_module modules/mod_proxy_scgi.so +#LoadModule proxy_uwsgi_module modules/mod_proxy_uwsgi.so +#LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so +#LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so +#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so +#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so +#LoadModule proxy_express_module modules/mod_proxy_express.so +#LoadModule proxy_hcheck_module modules/mod_proxy_hcheck.so +#LoadModule session_module modules/mod_session.so +#LoadModule session_cookie_module modules/mod_session_cookie.so +#LoadModule session_dbd_module modules/mod_session_dbd.so +#LoadModule slotmem_shm_module modules/mod_slotmem_shm.so +#LoadModule ssl_module modules/mod_ssl.so +#LoadModule http2_module modules/mod_http2.so +#LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so +#LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so +#LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so +#LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so +LoadModule unixd_module modules/mod_unixd.so +#LoadModule dav_module modules/mod_dav.so +LoadModule status_module modules/mod_status.so +LoadModule autoindex_module modules/mod_autoindex.so +#LoadModule info_module modules/mod_info.so +#LoadModule cgid_module modules/mod_cgid.so +#LoadModule dav_fs_module modules/mod_dav_fs.so +#LoadModule vhost_alias_module modules/mod_vhost_alias.so +#LoadModule negotiation_module modules/mod_negotiation.so +LoadModule dir_module modules/mod_dir.so +#LoadModule actions_module modules/mod_actions.so +#LoadModule speling_module modules/mod_speling.so +#LoadModule userdir_module modules/mod_userdir.so +LoadModule alias_module modules/mod_alias.so +#LoadModule rewrite_module modules/mod_rewrite.so + + +# +# If you wish httpd to run as a different user or group, you must run +# httpd as root initially and it will switch. +# +# User/Group: The name (or #number) of the user/group to run httpd as. +# It is usually good practice to create a dedicated user and group for +# running httpd, as with most system services. +# +User daemon +Group daemon + + + +# 'Main' server configuration +# +# The directives in this section set up the values used by the 'main' +# server, which responds to any requests that aren't handled by a +# definition. These values also provide defaults for +# any containers you may define later in the file. +# +# All of these directives may appear inside containers, +# in which case these default settings will be overridden for the +# virtual host being defined. +# + +# +# ServerAdmin: Your address, where problems with the server should be +# e-mailed. This address appears on some server-generated pages, such +# as error documents. e.g. admin@your-domain.com +# +ServerAdmin you@example.com + +# +# ServerName gives the name and port that the server uses to identify itself. +# This can often be determined automatically, but we recommend you specify +# it explicitly to prevent problems during startup. +# +# If your host doesn't have a registered DNS name, enter its IP address here. +# +#ServerName www.example.com:80 + +# +# Deny access to the entirety of your server's filesystem. You must +# explicitly permit access to web content directories in other +# blocks below. +# + + AllowOverride none + Require all denied + + +# +# Note that from this point forward you must specifically allow +# particular features to be enabled - so if something's not working as +# you might expect, make sure that you have specifically enabled it +# below. +# + +# +# DocumentRoot: The directory out of which you will serve your +# documents. By default, all requests are taken from this directory, but +# symbolic links and aliases may be used to point to other locations. +# +DocumentRoot "/Users/midoks/Desktop/mwdev/server/apache/httpd/htdocs" + + # + # Possible values for the Options directive are "None", "All", + # or any combination of: + # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews + # + # Note that "MultiViews" must be named *explicitly* --- "Options All" + # doesn't give it to you. + # + # The Options directive is both complicated and important. Please see + # http://httpd.apache.org/docs/2.4/mod/core.html#options + # for more information. + # + Options Indexes FollowSymLinks + + # + # AllowOverride controls what directives may be placed in .htaccess files. + # It can be "All", "None", or any combination of the keywords: + # AllowOverride FileInfo AuthConfig Limit + # + AllowOverride None + + # + # Controls who can get stuff from this server. + # + Require all granted + + +# +# DirectoryIndex: sets the file that Apache will serve if a directory +# is requested. +# + + DirectoryIndex index.html + + +# +# The following lines prevent .htaccess and .htpasswd files from being +# viewed by Web clients. +# + + Require all denied + + +# +# ErrorLog: The location of the error log file. +# If you do not specify an ErrorLog directive within a +# container, error messages relating to that virtual host will be +# logged here. If you *do* define an error logfile for a +# container, that host's errors will be logged there and not here. +# +ErrorLog "logs/error_log" + +# +# LogLevel: Control the number of messages logged to the error_log. +# Possible values include: debug, info, notice, warn, error, crit, +# alert, emerg. +# +LogLevel warn + + + # + # The following directives define some format nicknames for use with + # a CustomLog directive (see below). + # + LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined + LogFormat "%h %l %u %t \"%r\" %>s %b" common + + + # You need to enable mod_logio.c to use %I and %O + LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio + + + # + # The location and format of the access logfile (Common Logfile Format). + # If you do not define any access logfiles within a + # container, they will be logged here. Contrariwise, if you *do* + # define per- access logfiles, transactions will be + # logged therein and *not* in this file. + # + CustomLog "logs/access_log" common + + # + # If you prefer a logfile with access, agent, and referer information + # (Combined Logfile Format) you can use the following directive. + # + #CustomLog "logs/access_log" combined + + + + # + # Redirect: Allows you to tell clients about documents that used to + # exist in your server's namespace, but do not anymore. The client + # will make a new request for the document at its new location. + # Example: + # Redirect permanent /foo http://www.example.com/bar + + # + # Alias: Maps web paths into filesystem paths and is used to + # access content that does not live under the DocumentRoot. + # Example: + # Alias /webpath /full/filesystem/path + # + # If you include a trailing / on /webpath then the server will + # require it to be present in the URL. You will also likely + # need to provide a section to allow access to + # the filesystem path. + + # + # ScriptAlias: This controls which directories contain server scripts. + # ScriptAliases are essentially the same as Aliases, except that + # documents in the target directory are treated as applications and + # run by the server when requested rather than as documents sent to the + # client. The same rules about trailing "/" apply to ScriptAlias + # directives as to Alias. + # + ScriptAlias /cgi-bin/ "/Users/midoks/Desktop/mwdev/server/apache/httpd/cgi-bin/" + + + + + # + # ScriptSock: On threaded servers, designate the path to the UNIX + # socket used to communicate with the CGI daemon of mod_cgid. + # + #Scriptsock cgisock + + +# +# "/Users/midoks/Desktop/mwdev/server/apache/httpd/cgi-bin" should be changed to whatever your ScriptAliased +# CGI directory exists, if you have that configured. +# + + AllowOverride None + Options None + Require all granted + + + + # + # Avoid passing HTTP_PROXY environment to CGI's on this or any proxied + # backend servers which have lingering "httpoxy" defects. + # 'Proxy' request header is undefined by the IETF, not listed by IANA + # + RequestHeader unset Proxy early + + + + # + # TypesConfig points to the file containing the list of mappings from + # filename extension to MIME-type. + # + TypesConfig conf/mime.types + + # + # AddType allows you to add to or override the MIME configuration + # file specified in TypesConfig for specific file types. + # + #AddType application/x-gzip .tgz + # + # AddEncoding allows you to have certain browsers uncompress + # information on the fly. Note: Not all browsers support this. + # + #AddEncoding x-compress .Z + #AddEncoding x-gzip .gz .tgz + # + # If the AddEncoding directives above are commented-out, then you + # probably should define those extensions to indicate media types: + # + AddType application/x-compress .Z + AddType application/x-gzip .gz .tgz + + # + # AddHandler allows you to map certain file extensions to "handlers": + # actions unrelated to filetype. These can be either built into the server + # or added with the Action directive (see below) + # + # To use CGI scripts outside of ScriptAliased directories: + # (You will also need to add "ExecCGI" to the "Options" directive.) + # + #AddHandler cgi-script .cgi + + # For type maps (negotiated resources): + #AddHandler type-map var + + # + # Filters allow you to process content before it is sent to the client. + # + # To parse .shtml files for server-side includes (SSI): + # (You will also need to add "Includes" to the "Options" directive.) + # + #AddType text/html .shtml + #AddOutputFilter INCLUDES .shtml + + +# +# The mod_mime_magic module allows the server to use various hints from the +# contents of the file itself to determine its type. The MIMEMagicFile +# directive tells the module where the hint definitions are located. +# +#MIMEMagicFile conf/magic + +# +# Customizable error responses come in three flavors: +# 1) plain text 2) local redirects 3) external redirects +# +# Some examples: +#ErrorDocument 500 "The server made a boo boo." +#ErrorDocument 404 /missing.html +#ErrorDocument 404 "/cgi-bin/missing_handler.pl" +#ErrorDocument 402 http://www.example.com/subscription_info.html +# + +# +# MaxRanges: Maximum number of Ranges in a request before +# returning the entire resource, or one of the special +# values 'default', 'none' or 'unlimited'. +# Default setting is to accept 200 Ranges. +#MaxRanges unlimited + +# +# EnableMMAP and EnableSendfile: On systems that support it, +# memory-mapping or the sendfile syscall may be used to deliver +# files. This usually improves server performance, but must +# be turned off when serving from networked-mounted +# filesystems or if support for these functions is otherwise +# broken on your system. +# Defaults: EnableMMAP On, EnableSendfile Off +# +#EnableMMAP off +#EnableSendfile on + +# Supplemental configuration +# +# The configuration files in the conf/extra/ directory can be +# included to add extra features or to modify the default configuration of +# the server, or you may simply copy their contents here and change as +# necessary. + +# Server-pool management (MPM specific) +#Include conf/extra/httpd-mpm.conf + +# Multi-language error messages +#Include conf/extra/httpd-multilang-errordoc.conf + +# Fancy directory listings +#Include conf/extra/httpd-autoindex.conf + +# Language settings +#Include conf/extra/httpd-languages.conf + +# User home directories +#Include conf/extra/httpd-userdir.conf + +# Real-time info on requests and configuration +#Include conf/extra/httpd-info.conf + +# Virtual hosts +#Include conf/extra/httpd-vhosts.conf + +# Local access to the Apache HTTP Server Manual +#Include conf/extra/httpd-manual.conf + +# Distributed authoring and versioning (WebDAV) +#Include conf/extra/httpd-dav.conf + +# Various default settings +#Include conf/extra/httpd-default.conf + +# Configure mod_proxy_html to understand HTML4/XHTML1 + +Include conf/extra/proxy-html.conf + + +# Secure (SSL/TLS) connections +#Include conf/extra/httpd-ssl.conf +# +# Note: The following must must be present to support +# starting without SSL on platforms with no /dev/random equivalent +# but a statically compiled-in mod_ssl. +# + +SSLRandomSeed startup builtin +SSLRandomSeed connect builtin + + From 0fa462c385bdcd23bccc117b8de35405b8cd941e Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 20:36:17 +0800 Subject: [PATCH 19/76] Update index.py --- plugins/apache/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/apache/index.py b/plugins/apache/index.py index 7493175c8..15ac04a48 100755 --- a/plugins/apache/index.py +++ b/plugins/apache/index.py @@ -224,7 +224,7 @@ def restyOp(method): file = initDreplace() # 启动时,先检查一下配置文件 - check = getServerDir() + "/bin/httpd -t" + check = getServerDir() + "/apache/httpd/bin/httpd -t" check_data = mw.execShell(check) if not check_data[1].find('test is successful') > -1: return check_data[1] From b0133162f035ac8a462ab9c6102e9ddfe391e4c2 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 20:36:30 +0800 Subject: [PATCH 20/76] Update index.py --- plugins/apache/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/apache/index.py b/plugins/apache/index.py index 15ac04a48..458e1d319 100755 --- a/plugins/apache/index.py +++ b/plugins/apache/index.py @@ -266,7 +266,7 @@ def restyOp_restart(): file = initDreplace() # 启动时,先检查一下配置文件 - check = getServerDir() + "/bin/httpd -t" + check = getServerDir() + "/apache/httpd/bin/httpd -t" check_data = mw.execShell(check) if not check_data[1].find('test is successful') > -1: return 'ERROR: 配置出错
' + check_data[1].replace("\n", '
') + '
' From 732ad976bf59467922b15e00c42a2d3d7be0c90a Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 20:37:11 +0800 Subject: [PATCH 21/76] Update index.py --- plugins/apache/index.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/apache/index.py b/plugins/apache/index.py index 458e1d319..04db8b35b 100755 --- a/plugins/apache/index.py +++ b/plugins/apache/index.py @@ -310,7 +310,7 @@ def initdStatus(): if os.path.exists(initd_bin): return 'ok' - shell_cmd = 'systemctl status httpd | grep loaded | grep "enabled;"' + shell_cmd = 'systemctl status apache | grep loaded | grep "enabled;"' data = mw.execShell(shell_cmd) if data[0] == '': return 'fail' @@ -332,7 +332,7 @@ def initdInstall(): mw.execShell('sysrc ' + getPluginName() + '_enable="YES"') return 'ok' - mw.execShell('systemctl enable httpd') + mw.execShell('systemctl enable apache') return 'ok' @@ -347,7 +347,7 @@ def initdUinstall(): mw.execShell('sysrc ' + getPluginName() + '_enable="NO"') return 'ok' - mw.execShell('systemctl disable httpd') + mw.execShell('systemctl disable apache') return 'ok' def getNgxStatusPort(): From affea597bf9b2d27b091fa236d5646e99361c860 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 20:38:39 +0800 Subject: [PATCH 22/76] Update index.py --- plugins/apache/index.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/apache/index.py b/plugins/apache/index.py index 04db8b35b..83c6902bb 100755 --- a/plugins/apache/index.py +++ b/plugins/apache/index.py @@ -310,7 +310,7 @@ def initdStatus(): if os.path.exists(initd_bin): return 'ok' - shell_cmd = 'systemctl status apache | grep loaded | grep "enabled;"' + shell_cmd = 'systemctl status '+getPluginName()+' | grep loaded | grep "enabled;"' data = mw.execShell(shell_cmd) if data[0] == '': return 'fail' @@ -332,7 +332,7 @@ def initdInstall(): mw.execShell('sysrc ' + getPluginName() + '_enable="YES"') return 'ok' - mw.execShell('systemctl enable apache') + mw.execShell('systemctl enable '+getPluginName()) return 'ok' @@ -347,7 +347,7 @@ def initdUinstall(): mw.execShell('sysrc ' + getPluginName() + '_enable="NO"') return 'ok' - mw.execShell('systemctl disable apache') + mw.execShell('systemctl disable '+getPluginName()) return 'ok' def getNgxStatusPort(): From fc5acaf0be1344dc79f4b4e903433155c1282fa8 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 20:40:07 +0800 Subject: [PATCH 23/76] Update index.py --- plugins/apache/index.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/apache/index.py b/plugins/apache/index.py index 83c6902bb..563aace3f 100755 --- a/plugins/apache/index.py +++ b/plugins/apache/index.py @@ -224,7 +224,7 @@ def restyOp(method): file = initDreplace() # 启动时,先检查一下配置文件 - check = getServerDir() + "/apache/httpd/bin/httpd -t" + check = getServerDir() + "/httpd/bin/httpd -t" check_data = mw.execShell(check) if not check_data[1].find('test is successful') > -1: return check_data[1] @@ -237,12 +237,12 @@ def restyOp(method): return data[1] if current_os.startswith("freebsd"): - data = mw.execShell('service httpd ' + method) + mw.execShell('service '+getPluginName()+' '+method) if data[1] == '': return 'ok' return data[1] - data = mw.execShell('systemctl ' + method + ' httpd') + data = mw.execShell('systemctl ' + method + ' '+getPluginName()) if data[1] == '': return 'ok' return data[1] @@ -251,10 +251,10 @@ def restyOp(method): def op_submit_systemctl_restart(): current_os = mw.getOs() if current_os.startswith("freebsd"): - mw.execShell('service httpd restart') + mw.execShell('service '+getPluginName()+' restart') return True - mw.execShell('systemctl restart httpd') + mw.execShell('systemctl restart '+getPluginName()) return True @@ -266,7 +266,7 @@ def restyOp_restart(): file = initDreplace() # 启动时,先检查一下配置文件 - check = getServerDir() + "/apache/httpd/bin/httpd -t" + check = getServerDir() + "/httpd/bin/httpd -t" check_data = mw.execShell(check) if not check_data[1].find('test is successful') > -1: return 'ERROR: 配置出错
' + check_data[1].replace("\n", '
') + '
' From 530347c84795db61d9aa843a86946ef81ec32039 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 20:41:55 +0800 Subject: [PATCH 24/76] Update index.py --- plugins/apache/index.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/apache/index.py b/plugins/apache/index.py index 563aace3f..490a36b3d 100755 --- a/plugins/apache/index.py +++ b/plugins/apache/index.py @@ -226,7 +226,7 @@ def restyOp(method): # 启动时,先检查一下配置文件 check = getServerDir() + "/httpd/bin/httpd -t" check_data = mw.execShell(check) - if not check_data[1].find('test is successful') > -1: + if not check_data[1].find('Syntax OK') > -1: return check_data[1] current_os = mw.getOs() @@ -268,7 +268,7 @@ def restyOp_restart(): # 启动时,先检查一下配置文件 check = getServerDir() + "/httpd/bin/httpd -t" check_data = mw.execShell(check) - if not check_data[1].find('test is successful') > -1: + if not check_data[1].find('Syntax OK') > -1: return 'ERROR: 配置出错
' + check_data[1].replace("\n", '
') + '
' if not mw.isAppleSystem(): @@ -567,7 +567,7 @@ def installPreInspection(): if __name__ == "__main__": - version = '1.27.1' + version = '2.4' version_pl = getServerDir() + "/version.pl" if os.path.exists(version_pl): version = mw.readFile(version_pl) From e966df976ffb402c43094d188e27a954e6e1ee63 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 20:42:40 +0800 Subject: [PATCH 25/76] Update index.py --- plugins/apache/index.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/apache/index.py b/plugins/apache/index.py index 490a36b3d..b36684f50 100755 --- a/plugins/apache/index.py +++ b/plugins/apache/index.py @@ -310,7 +310,7 @@ def initdStatus(): if os.path.exists(initd_bin): return 'ok' - shell_cmd = 'systemctl status '+getPluginName()+' | grep loaded | grep "enabled;"' + shell_cmd = 'systemctl status httpd | grep loaded | grep "enabled;"' data = mw.execShell(shell_cmd) if data[0] == '': return 'fail' @@ -329,10 +329,10 @@ def initdInstall(): initd_bin = getInitDFile() shutil.copyfile(source_bin, initd_bin) mw.execShell('chmod +x ' + initd_bin) - mw.execShell('sysrc ' + getPluginName() + '_enable="YES"') + mw.execShell('sysrc httpd_enable="YES"') return 'ok' - mw.execShell('systemctl enable '+getPluginName()) + mw.execShell('systemctl enable httpd') return 'ok' @@ -344,10 +344,10 @@ def initdUinstall(): if current_os.startswith('freebsd'): initd_bin = getInitDFile() os.remove(initd_bin) - mw.execShell('sysrc ' + getPluginName() + '_enable="NO"') + mw.execShell('sysrc httpd_enable="NO"') return 'ok' - mw.execShell('systemctl disable '+getPluginName()) + mw.execShell('systemctl disable httpd') return 'ok' def getNgxStatusPort(): From b97e0df6c5bf6680b0267935a115e8b86ea29f7e Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 20:44:54 +0800 Subject: [PATCH 26/76] Update index.py --- plugins/apache/index.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/apache/index.py b/plugins/apache/index.py index b36684f50..359c46a49 100755 --- a/plugins/apache/index.py +++ b/plugins/apache/index.py @@ -237,12 +237,12 @@ def restyOp(method): return data[1] if current_os.startswith("freebsd"): - mw.execShell('service '+getPluginName()+' '+method) + mw.execShell('service httpd '+method) if data[1] == '': return 'ok' return data[1] - data = mw.execShell('systemctl ' + method + ' '+getPluginName()) + data = mw.execShell('systemctl ' + method + ' httpd') if data[1] == '': return 'ok' return data[1] From 91d189cf003e807002e00a60382116fc9753e7c8 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 20:45:19 +0800 Subject: [PATCH 27/76] Update index.py --- plugins/apache/index.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugins/apache/index.py b/plugins/apache/index.py index 359c46a49..61c7431c5 100755 --- a/plugins/apache/index.py +++ b/plugins/apache/index.py @@ -285,9 +285,6 @@ def start(): def stop(): r = restyOp('stop') - pid_file = getPidFile() - if os.path.exists(pid_file): - os.remove(pid_file) return r From 9a976fdd3c6c984e398e92ba912cc2e00d113550 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 20:56:29 +0800 Subject: [PATCH 28/76] update --- plugins/apache/conf/httpd.conf | 6 +++-- plugins/apache/index.py | 47 ++-------------------------------- 2 files changed, 6 insertions(+), 47 deletions(-) diff --git a/plugins/apache/conf/httpd.conf b/plugins/apache/conf/httpd.conf index 41aff4bce..933e722a9 100644 --- a/plugins/apache/conf/httpd.conf +++ b/plugins/apache/conf/httpd.conf @@ -48,8 +48,8 @@ ServerRoot "/Users/midoks/Desktop/mwdev/server/apache/httpd" # Change this to Listen on specific IP addresses as shown below to # prevent Apache from glomming onto all bound IP addresses. # -#Listen 12.34.56.78:80 -Listen 80 +#Listen 127.0.0.1:8280 +Listen 8280 # # Dynamic Shared Object (DSO) Support @@ -504,3 +504,5 @@ SSLRandomSeed startup builtin SSLRandomSeed connect builtin + + diff --git a/plugins/apache/index.py b/plugins/apache/index.py index 61c7431c5..d1c691744 100755 --- a/plugins/apache/index.py +++ b/plugins/apache/index.py @@ -70,12 +70,8 @@ def checkArgs(data, ck=[]): def clearTemp(): - path_bin = getServerDir() + "/apache/httpd" + path_bin = getServerDir() + "/httpd" mw.execShell('rm -rf ' + path_bin + '/client_body_temp') - mw.execShell('rm -rf ' + path_bin + '/fastcgi_temp') - mw.execShell('rm -rf ' + path_bin + '/proxy_temp') - mw.execShell('rm -rf ' + path_bin + '/scgi_temp') - mw.execShell('rm -rf ' + path_bin + '/uwsgi_temp') def getConf(): @@ -128,49 +124,10 @@ def confReplace(): content = mw.readFile(getConfTpl()) content = content.replace('{$SERVER_PATH}', service_path) - user = 'www' - user_group = 'www' - - content = content.replace('{$OS_USER}', user) - content = content.replace('{$OS_USER_GROUP}', user_group) - - # ng_conf_md5 = '' - # ng_conf_md5_file = getServerDir() + '/nginx_conf.md5' - # if not os.path.exists(ng_conf_md5_file): - # ng_conf_md5 = mw.md5(content) - # mw.writeFile(ng_conf_md5_file, ng_conf_md5) - # else: - # ng_conf_md5 = mw.writeFile(ng_conf_md5_file).strip() - # 主配置文件 - nconf = getServerDir() + '/nginx/conf/nginx.conf' + nconf = getServerDir() + '/httpd/conf/httpd.conf' mw.writeFile(nconf, content) - # lua配置 - lua_conf_dir = mw.getServerDir() + '/web_conf/nginx/lua' - if not os.path.exists(lua_conf_dir): - mw.execShell('mkdir -p ' + lua_conf_dir) - # 静态配置 - php_conf = mw.getServerDir() + '/web_conf/php/conf' - if not os.path.exists(php_conf): - mw.execShell('mkdir -p ' + php_conf) - static_conf = mw.getServerDir() + '/web_conf/php/conf/enable-php-00.conf' - if not os.path.exists(static_conf): - mw.writeFile(static_conf, 'set $PHP_ENV 0;') - - # vhost - vhost_dir = mw.getServerDir() + '/web_conf/nginx/vhost' - vhost_tpl_dir = getPluginDir() + '/conf/vhost' - if not os.path.exists(vhost_dir): - mw.execShell('mkdir -p ' + vhost_dir) - - vhost_list = ['0.websocket.conf', '0.nginx_status.conf'] - for f in vhost_list: - a_conf = vhost_dir + '/' + f - a_conf_tpl = vhost_tpl_dir + '/' + f - if not os.path.exists(a_conf): - mw.writeFile(a_conf, mw.readFile(a_conf_tpl)) - def initDreplace(): From 0670bca67d8bdf95aa8bbc97b1274152f468bd74 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 21:00:23 +0800 Subject: [PATCH 29/76] Update index.py --- plugins/apache/index.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/plugins/apache/index.py b/plugins/apache/index.py index d1c691744..9cd8f0aa8 100755 --- a/plugins/apache/index.py +++ b/plugins/apache/index.py @@ -304,9 +304,13 @@ def initdUinstall(): mw.execShell('systemctl disable httpd') return 'ok' -def getNgxStatusPort(): - ngx_status_file = mw.getServerDir() + '/web_conf/nginx/vhost/0.nginx_status.conf' - content = mw.readFile(ngx_status_file) +def getHttpdStatusPort(): + conf = mw.getServerDir() + '/httpd/conf/httpd.conf' + content = mw.readFile(conf) + + print(content) + + rep = r'listen\s*(.*);' tmp = re.search(rep, content) port = tmp.groups()[0].strip() @@ -318,11 +322,13 @@ def runInfo(): if op_status == 'stop': return mw.returnJson(False, "未启动!") - port = getNgxStatusPort() + port = getHttpdStatusPort() # 取Openresty负载状态 try: - url = 'http://127.0.0.1:%s/nginx_status' % port + url = 'http://127.0.0.1:%s/server-status?auto' % port result = mw.httpGet(url, timeout=3) + + print(result) tmp = result.split() data = {} data['active'] = tmp[2] @@ -335,7 +341,7 @@ def runInfo(): return mw.getJson(data) except Exception as e: try: - url = 'http://' + mw.getHostAddr() + ':%s/nginx_status' % port + url = 'http://' + mw.getHostAddr() + ':%s/server-status?auto' % port result = mw.httpGet(url) tmp = result.split() data = {} From b975fedfeefe5ea3c93a907aea7f261757baad02 Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 11 Apr 2026 21:24:15 +0800 Subject: [PATCH 30/76] update --- plugins/apache/index.html | 5 +-- plugins/apache/index.py | 62 ++++++++++++++++++------------------ plugins/apache/js/httpd.js | 65 +++++++++++++++++++++++++++++++------- 3 files changed, 89 insertions(+), 43 deletions(-) diff --git a/plugins/apache/index.html b/plugins/apache/index.html index 62a7d71df..3a57b2104 100755 --- a/plugins/apache/index.html +++ b/plugins/apache/index.html @@ -5,19 +5,20 @@

服务

自启动

配置修改

-

负载状态

+

负载状态

性能调整

错误日志

维护功能

-
+