diff --git a/class/core/mw.py b/class/core/mw.py index bf9c23f89..0cf6893d6 100755 --- a/class/core/mw.py +++ b/class/core/mw.py @@ -441,7 +441,7 @@ def writeFile(filename, content, mode='w+'): # 写文件内容 try: fp = open(filename, mode) - fp.write(content.encode('utf-8')) + fp.write(content) fp.close() return True except Exception as e: diff --git a/class/core/site_api.py b/class/core/site_api.py index 1ee7ab35f..69268a924 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -2305,8 +2305,7 @@ location ^~ {from} { # 写入数据库 pid = mw.M('sites').add('name,path,status,ps,edate,addtime,type_id', (self.siteName, self.sitePath, '1', ps, '0000-00-00', mw.getDate(), 0,)) - opid = mw.M('domain').where( - "name=?", (self.siteName,)).getField('pid') + opid = mw.M('domain').where("name=?", (self.siteName,)).getField('pid') if opid: if mw.M('sites').where('id=?', (opid,)).count(): return mw.returnJson(False, '您添加的域名已存在!') @@ -2399,8 +2398,9 @@ location ^~ {from} { tmp = re.findall(rep, conf) if not mw.inArray(tmp, '443'): listen = re.search(rep, conf).group() + http_ssl = "\n\tlisten 443 ssl http2;" conf = conf.replace( - listen, listen + "\n\tlisten 443 ssl http2;") + listen, listen + http_ssl) shutil.copyfile(file, '/tmp/backup.conf') mw.writeFile(file, conf) @@ -2409,11 +2409,12 @@ location ^~ {from} { shutil.copyfile('/tmp/backup.conf', file) return mw.returnData(False, '证书错误:
' + isError.replace("\n", '
') + '
') - mw.restartWeb() self.saveCert(keyPath, certPath) msg = mw.getInfo('网站[{1}]开启SSL成功!', siteName) mw.writeLog('网站管理', msg) + + mw.restartWeb() return mw.returnData(True, 'SSL开启成功!') def saveCert(self, keyPath, certPath): diff --git a/data/tpl/nginx.conf b/data/tpl/nginx.conf index ee8383cc0..94f96ad2b 100755 --- a/data/tpl/nginx.conf +++ b/data/tpl/nginx.conf @@ -2,7 +2,6 @@ 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};