From 5f144924e48f0e3ae25a50d4018c656793834b55 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Tue, 26 Nov 2024 05:02:47 +0800 Subject: [PATCH] update --- data/tpl/nginx.conf | 53 ------------------------------------- data/tpl/nginx_dirbind.conf | 48 --------------------------------- data/tpl/nginx_panel.conf | 23 ---------------- web/utils/site.py | 16 ++++++----- 4 files changed, 10 insertions(+), 130 deletions(-) delete mode 100755 data/tpl/nginx.conf delete mode 100755 data/tpl/nginx_dirbind.conf delete mode 100755 data/tpl/nginx_panel.conf diff --git a/data/tpl/nginx.conf b/data/tpl/nginx.conf deleted file mode 100755 index 5da306f9d..000000000 --- a/data/tpl/nginx.conf +++ /dev/null @@ -1,53 +0,0 @@ -server -{ - # reuseport 只能在一个server出现一次 - listen {$PORT}; - listen [::]:{$PORT}; - server_name {$SERVER_NAME}; - index index.php index.html index.htm default.php default.htm default.html; - root {$ROOT_DIR}; - - #SSL-START - #error_page 404/404.html; - #SSL-END - - #301-START - - #PROXY-START - - #ERROR-PAGE-START - #error_page 404 /404.html; - #error_page 502 /502.html; - #ERROR-PAGE-END - - #PHP-INFO-START - include {$PHP_DIR}/conf/enable-php-{$PHPVER}.conf; - #PHP-INFO-END - - #REWRITE-START - include {$OR_REWRITE}/{$SERVER_NAME}.conf; - #REWRITE-END - - #禁止访问的文件或目录 - location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md) - { - return 404; - } - - #一键申请SSL证书验证目录相关设置 - location ~ \.well-known{ - allow all; - } - - location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|ttf|woff2)$ - { - expires 30d; - access_log /dev/null; - if ($invalid_referer){ - return 404; - } - } - - access_log {$LOGPATH}/{$SERVER_NAME}.log main; - error_log {$LOGPATH}/{$SERVER_NAME}.error.log; -} \ No newline at end of file diff --git a/data/tpl/nginx_dirbind.conf b/data/tpl/nginx_dirbind.conf deleted file mode 100755 index 129a7ddd1..000000000 --- a/data/tpl/nginx_dirbind.conf +++ /dev/null @@ -1,48 +0,0 @@ - -#BINDING-{$DIRBIND}-START -server -{ - listen {$PORT}; - server_name {$DIRBIND}; - index index.php index.html index.htm default.php default.htm default.html; - root {$ROOT_DIR}; - - #SSL-START - #error_page 404/404.html; - #SSL-END - - #ERROR-PAGE-START - #error_page 404 /404.html; - #error_page 502 /502.html; - #ERROR-PAGE-END - - #PHP-INFO-START - include {$PHP_DIR}/conf/enable-php-{$PHPVER}.conf; - #PHP-INFO-END - - #REWRITE-START - include {$OR_REWRITE}/{$SERVER_MAIN}.conf; - #REWRITE-END - - #禁止访问的文件或目录 - location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md) - { - return 404; - } - - #一键申请SSL证书验证目录相关设置 - location ~ \.well-known{ - allow all; - } - - location ~ .*\\.(gif|jpg|jpeg|png|bmp|swf|js|css)$ - { - error_log /dev/null; - access_log /dev/null; - expires 30d; - } - - access_log {$LOGPATH}/{$SERVER_MAIN}_{$DIRBIND}.log; - error_log {$LOGPATH}/{$SERVER_MAIN}_{$DIRBIND}.error.log; -} -#BINDING-{$DIRBIND}-END \ No newline at end of file diff --git a/data/tpl/nginx_panel.conf b/data/tpl/nginx_panel.conf deleted file mode 100755 index c487094fd..000000000 --- a/data/tpl/nginx_panel.conf +++ /dev/null @@ -1,23 +0,0 @@ -server -{ - listen {$PORT}; - listen [::]:{$PORT}; - - server_name {$SERVER_NAME}; - index index.php index.html index.htm default.php default.htm default.html; - - #SSL-START - #error_page 404/404.html; - #SSL-END - - #PROXY-START - location ^~ / { - proxy_pass http://0.0.0.0:{$PANAL_PORT}/; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection 'upgrade'; - } - #PROXY-END - - error_log {$LOGPATH}/{$SERVER_NAME}.error.log; -} \ No newline at end of file diff --git a/web/utils/site.py b/web/utils/site.py index a61d0e932..b2e0df56c 100644 --- a/web/utils/site.py +++ b/web/utils/site.py @@ -421,7 +421,8 @@ class sites(object): return mw.returnData(True, '站点【%s】删除成功!' % webname) def nginxAddConf(self): - source_tpl = mw.getPanelDir() + '/data/tpl/nginx.conf' + + source_tpl = self.getNgxTplDir() + '/nginx.conf' vhost_file = self.getHostConf(self.siteName) content = mw.readFile(source_tpl) @@ -605,17 +606,20 @@ class sites(object): return mw.returnData(True, mw.getLastLine(logPath, 100)) def getNgxRewriteDir(self): - return mw.getPanelDir() + '/web/misc/nginx/rewrite/' + return mw.getPanelDir() + '/web/misc/nginx/rewrite' + + def getNgxTplDir(self): + return mw.getPanelDir() + '/web/misc/nginx/tpl' # 获取模版名内容 - def getRewriteTpl(self, tplname): - file = self.getNgxRewriteDir() + tplname + '.conf' + def getRewriteTpl(self, name): + path = self.getNgxRewriteDir() +'/'+ name + ".conf" if not os.path.exists(file): return mw.returnData(False, '模版不存在!') return mw.returnData(True, 'OK', file) def setRewriteTpl(self,name,data): - path = self.getNgxRewriteDir() + name + ".conf" + path = self.getNgxRewriteDir() +'/'+ name + ".conf" if os.path.exists(path): return mw.returnData(False, '模版已经存在!') @@ -820,7 +824,7 @@ class sites(object): domain_split = re.search(rep, conf).groups() version = domain_split[0] - source_dirbind_tpl = mw.getPanelDir() + '/data/tpl/nginx_dirbind.conf' + source_dirbind_tpl = self.getNgxTplDir() + '/nginx_dirbind.conf' content = mw.readFile(source_dirbind_tpl) content = content.replace('{$PORT}', port) content = content.replace('{$PHPVER}', version)