From eaba13df5b7dd4c0be2dffcab279965a621d2655 Mon Sep 17 00:00:00 2001 From: wangbo Date: Wed, 14 May 2025 22:36:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6=E6=9D=83?= =?UTF-8?q?=E9=99=90=EF=BC=9A=E6=8F=8F=E8=BF=B0=E6=9D=83=E9=99=90=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E7=9A=84=E5=8E=9F=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 ++++ .idea/UniappTool.xml | 10 +++++ .idea/easyai.iml | 12 ++++++ .idea/modules.xml | 8 ++++ .idea/vcs.xml | 6 +++ easyai-proxy.conf | 6 +++ https.sh | 90 ++++++++++++++++++++++++++++++++++++++++++-- 7 files changed, 136 insertions(+), 4 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/UniappTool.xml create mode 100644 .idea/easyai.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/UniappTool.xml b/.idea/UniappTool.xml new file mode 100644 index 0000000..f7328e8 --- /dev/null +++ b/.idea/UniappTool.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/.idea/easyai.iml b/.idea/easyai.iml new file mode 100644 index 0000000..24643cc --- /dev/null +++ b/.idea/easyai.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..167046b --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/easyai-proxy.conf b/easyai-proxy.conf index 8871bca..b0c5f15 100644 --- a/easyai-proxy.conf +++ b/easyai-proxy.conf @@ -49,6 +49,12 @@ server { try_files $uri =404; } + # 专门处理企业微信验证文件的请求 +# location = /WW_verify_9eWb5ozYfqE0Bb2i.txt { +# default_type text/plain; # 设置正确的Content-Type +# return 200 '9eWb5ozYfqE0Bb2i'; # 直接返回验证内容 +# } + location / { proxy_pass http://127.0.0.1:3010/; proxy_redirect off; # 修改重定向处理 diff --git a/https.sh b/https.sh index 2c47d83..bc11f8d 100755 --- a/https.sh +++ b/https.sh @@ -1,18 +1,100 @@ -# 检查 Nginx 是否已安装 if command -v nginx &> /dev/null; then echo "✅ Nginx 已安装,跳过安装步骤" else echo "🚀 安装 Nginx" - apt install -y nginx + # 检测系统类型 + if command -v apt &> /dev/null; then + # Debian/Ubuntu 系统 + apt install -y nginx + elif command -v yum &> /dev/null; then + # CentOS/RHEL 系统 + yum install -y nginx + elif command -v dnf &> /dev/null; then + # 较新版本的 Fedora/RHEL 系统 + dnf install -y nginx + else + echo "❌ 不支持的操作系统:未找到支持的包管理器" + exit 1 + fi fi +# 函数:尝试使用指定的包管理器安装 +try_install() { + local cmd=$1 + if command -v "$cmd" &> /dev/null; then + echo "📦 尝试使用 $cmd 安装 snapd..." + if sudo "$cmd" install -y snapd; then + return 0 + fi + fi + return 1 +} + # 检查 Certbot 是否已安装 if command -v certbot &> /dev/null; then echo "✅ Certbot 已安装,跳过安装步骤" else echo "🚀 安装 Certbot" - sudo apt install -y certbot - sudo apt install -y python3-certbot-nginx + + # 检测系统类型 + if [ -f /etc/debian_version ]; then + # Ubuntu/Debian 系统 + apt install -y certbot python3-certbot-nginx + elif [ -f /etc/redhat-release ]; then + # CentOS/RHEL 系统 + # 首先安装 EPEL 仓库 + yum install -y epel-release + # 安装 snapd + # 检查是否已安装 + if command -v snap &> /dev/null; then + echo "✅ snapd 已经安装" + exit 0 + fi + + echo "🔍 检测系统包管理器..." + + # 尝试使用 dnf 安装 + if try_install "dnf"; then + echo "✅ 使用 dnf 安装 snapd 成功" + + # 尝试使用 yum 安装 + elif try_install "yum"; then + echo "✅ 使用 yum 安装 snapd 成功" + + # 尝试使用 apt-get 安装(适用于 Debian/Ubuntu) + elif try_install "apt-get"; then + echo "✅ 使用 apt-get 安装 snapd 成功" + + else + echo "❌ 无法安装 snapd,未找到支持的包管理器" + exit 1 + fi + + # 启用 snapd 服务 + systemctl enable --now snapd.socket + + # 创建符号链接 + ln -s /var/lib/snapd/snap /snap + + # 安装 certbot + snap install --classic certbot + # Prepare the Certbot command + sudo ln -s /snap/bin/certbot /usr/bin/certbot + else + echo "❌ 不支持的操作系统" + exit 1 + fi +fi + +# 验证安装 +echo "🔍 验证安装" +if command -v nginx &> /dev/null && command -v certbot &> /dev/null; then + echo "✅ Nginx 和 Certbot 安装成功" + nginx -v + certbot --version +else + echo "❌ 安装验证失败" + exit 1 fi echo "🚀 复制当前目录的配置文件到nginx配置文件目录"