Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mouday committed Apr 17, 2024
1 parent d1693cb commit 9f4ae32
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 30 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
- v1.6.27(2024-04-16)
- fix
- 尝试修复运行超时数据库链接断开问题

- v1.6.26(2024-04-11)
Expand Down
33 changes: 4 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,37 +102,12 @@ QQ群号: 731742868

## 使用者

虚位以待
虚位以待(可以将使用者公司或个人的名字放到这里)

## 赞助商

| 日期 | 姓名 | 金额 |
| - | - | - |
| 2023-11-21 | [@1275788667](https://github.com/1275788667) | ¥50.00
| 2024-01-05 | [@hhdebb](https://github.com/hhdebb) | ¥50.00
- [@1275788667](https://github.com/1275788667)
- [@hhdebb](https://github.com/hhdebb)
- `星河 ๑. `

<img src="https://gitee.com/mouday/domain-admin/raw/master/image/alipay.jpg" width="300">

## Domain Cloud 众筹

由于本项目需要使用者自行安装,对于使用有一定的技术门槛,所以发起一个众筹

资金将用于部署一个线上版本的domain-admin,直接通过网页就可以使用

目标:¥2000

配置:一个域名 + 一台服务器

<img src="https://gitee.com/mouday/domain-admin/raw/master/image/afdian-吃个大西瓜.jpeg" width="300">

## 友情链接:

- [小熊猫去水印](https://qushuiyin.guijianpan.com)
- [ICP备案查询:ICP_Query](https://github.com/HG-ha/ICP_Query)
- [ICP备案查询:ICP-Checker](https://github.com/wongzeon/ICP-Checker)

- [某查询网站点选逆向分析](https://mp.weixin.qq.com/s/1Dw7ylfRmBjV_khOF4nuGQ)
- [文字点选验证码-破解之路](https://mp.weixin.qq.com/s/Lo9GveZUpnn_NTF8jL2ORg)

[![Stargazers over time](https://starchart.cc/mouday/domain-admin.svg)](https://starchart.cc/mouday/domain-admin)

9 changes: 9 additions & 0 deletions doc/source/manual/plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,12 @@
- `已完成` 通知配置增加分组参数
- `已完成` 主机host管理列表,支持移除
- 通过webhook重启

一些又有的链接

- [小熊猫去水印](https://qushuiyin.guijianpan.com)
- [ICP备案查询:ICP_Query](https://github.com/HG-ha/ICP_Query)
- [ICP备案查询:ICP-Checker](https://github.com/wongzeon/ICP-Checker)

- [某查询网站点选逆向分析](https://mp.weixin.qq.com/s/1Dw7ylfRmBjV_khOF4nuGQ)
- [文字点选验证码-破解之路](https://mp.weixin.qq.com/s/Lo9GveZUpnn_NTF8jL2ORg)
79 changes: 79 additions & 0 deletions doc/source/manual/ssl-cert.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,85 @@ if __name__ == '__main__':
app.run(port=8082)
```

完整示例,由群友 `@星河 ๑.`提供

```python
import os
import shutil
import subprocess
import threading
import time
from flask import Flask, request, jsonify

app = Flask(__name__)

def delayed_restart_nginx():
"""在延迟5秒后重启nginx"""
time.sleep(5)
try:
subprocess.run(['docker', 'restart', 'nginx'])
print('重启nginx完成。')
except subprocess.CalledProcessError as e:
print('重启nginx失败: ', e)

@app.route('/deploy-cert', methods=['POST'])
def deploy_cert():
token = request.headers.get('token')
if token != 'token':
return jsonify({'error': 'Invalid token'}), 401

# 获取请求参数
data = request.get_json()
# 获取域名列表
domains = data.get('domains', [])
# 获取证书文件
ssl_certificate = data.get('ssl_certificate', '')
# 获取证书密钥
ssl_certificate_key = data.get('ssl_certificate_key', '')

# 检测是否有值,避免无效请求
if not domains or not ssl_certificate or not ssl_certificate_key:
return jsonify({'error': 'Missing required fields'}), 400

# 定义基础路径,因为本人的 nginx 是 docker 运行的,做了磁盘映射
# nginx 的配置文件都在此目录,加上域名作为不同域名的证书目录
# 如:/server/dockerApps/nginx/nginx/certs/simple.com/fullchain.pem
# 如:/server/dockerApps/nginx/nginx/certs/simple.com/cert.key
base_path = '/server/dockerApps/nginx/nginx/certs'

# 遍历域名列表
for domain in domains:
# 将泛域名中的 *. 去掉
if domain.startswith('*.'):
domain = domain.replace('*.', '', 1)
# 创建目录
domain_dir = os.path.join(base_path, domain)
if os.path.exists(domain_dir):
shutil.rmtree(domain_dir)
os.makedirs(domain_dir)

# 生成证书文件
cert_path = os.path.join(domain_dir, 'fullchain.pem')
key_path = os.path.join(domain_dir, 'cert.key')

with open(cert_path, 'w') as cert_file:
cert_file.write(ssl_certificate)

with open(key_path, 'w') as key_file:
key_file.write(ssl_certificate_key)

print(domain, " ==> 证书创建成功")

# 执行重启nginx的线程
threading.Thread(target=delayed_restart_nginx).start()

# 返回前端结果
return jsonify({'result': 'ok'}), 200

if __name__ == '__main__':
app.run(host='0.0.0.0', port=8001)
```

## 说明

- 如果是全程采用`一键部署`方式操作,域名到期前30天会自动续期
Expand Down

0 comments on commit 9f4ae32

Please sign in to comment.