Files
2025-11-21 23:18:13 +08:00

50 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# SSL证书初始化脚本
# 用于首次申请Let's Encrypt证书
set -e
DOMAIN="www.omniverseai.net"
EMAIL="admin@omniverseai.net" # 请修改为您的实际邮箱
echo "正在为域名 ${DOMAIN} 申请SSL证书..."
# 创建必要的目录
mkdir -p ./certbot/conf
mkdir -p ./certbot/www
# 启动nginx和certbot服务
docker-compose -f docker-compose.prod.yml up -d nginx
# 等待nginx启动
echo "等待Nginx启动..."
sleep 5
# 申请证书
echo "申请SSL证书..."
docker-compose -f docker-compose.prod.yml run --rm certbot certonly \
--webroot \
--webroot-path=/var/www/certbot \
--email ${EMAIL} \
--agree-tos \
--no-eff-email \
-d ${DOMAIN} \
-d omniverseai.net
if [ $? -eq 0 ]; then
echo "SSL证书申请成功!"
echo ""
echo "接下来的步骤:"
echo "1. 编辑 nginx/default.conf"
echo "2. 取消注释HTTPS服务器配置块"
echo "3. 注释或删除HTTP配置中的临时proxy_pass"
echo "4. 取消注释HTTP到HTTPS重定向"
echo "5. 运行: docker-compose -f docker-compose.prod.yml restart nginx"
else
echo "SSL证书申请失败,请检查:"
echo "1. 域名DNS是否正确解析到本服务器"
echo "2. 80端口是否可以从外网访问"
echo "3. 邮箱地址是否正确"
fi