fix: 修复SSL证书部署时的文件检查问题
修复内容: 1. 修复HTTPS重定向配置 - 根据端口生成正确的重定向URL 2. 增强acme.sh文件存在性检查 - 在申请和安装证书前都检查文件 3. 应用到所有acme.sh方案 - Let's Encrypt、ZeroSSL、Buypass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
51
install.sh
51
install.sh
@@ -1464,6 +1464,13 @@ deploy_acme_letsencrypt() {
|
||||
# 申请证书
|
||||
echo ""
|
||||
print_info "正在申请 Let's Encrypt 证书..."
|
||||
|
||||
# 再次确认acme.sh存在
|
||||
if [[ ! -f ~/.acme.sh/acme.sh ]]; then
|
||||
print_error "acme.sh文件不存在: ~/.acme.sh/acme.sh"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ~/.acme.sh/acme.sh --issue -d "$DOMAIN" --nginx; then
|
||||
print_success "证书申请成功"
|
||||
else
|
||||
@@ -1480,6 +1487,13 @@ deploy_acme_letsencrypt() {
|
||||
# 安装证书
|
||||
echo ""
|
||||
print_info "正在安装证书到Nginx..."
|
||||
|
||||
# 再次确认acme.sh存在
|
||||
if [[ ! -f ~/.acme.sh/acme.sh ]]; then
|
||||
print_error "acme.sh文件不存在: ~/.acme.sh/acme.sh"
|
||||
return 1
|
||||
fi
|
||||
|
||||
mkdir -p /etc/nginx/ssl
|
||||
if ~/.acme.sh/acme.sh --install-cert -d "$DOMAIN" \
|
||||
--key-file /etc/nginx/ssl/${DOMAIN}.key \
|
||||
@@ -1599,6 +1613,13 @@ deploy_acme_zerossl() {
|
||||
# 申请证书
|
||||
echo ""
|
||||
print_info "正在申请 ZeroSSL 证书..."
|
||||
|
||||
# 再次确认acme.sh存在
|
||||
if [[ ! -f ~/.acme.sh/acme.sh ]]; then
|
||||
print_error "acme.sh文件不存在: ~/.acme.sh/acme.sh"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ~/.acme.sh/acme.sh --server zerossl --issue -d "$DOMAIN" --nginx; then
|
||||
print_success "证书申请成功"
|
||||
else
|
||||
@@ -1609,6 +1630,13 @@ deploy_acme_zerossl() {
|
||||
# 安装证书
|
||||
echo ""
|
||||
print_info "正在安装证书到Nginx..."
|
||||
|
||||
# 再次确认acme.sh存在
|
||||
if [[ ! -f ~/.acme.sh/acme.sh ]]; then
|
||||
print_error "acme.sh文件不存在: ~/.acme.sh/acme.sh"
|
||||
return 1
|
||||
fi
|
||||
|
||||
mkdir -p /etc/nginx/ssl
|
||||
if ~/.acme.sh/acme.sh --install-cert -d "$DOMAIN" \
|
||||
--key-file /etc/nginx/ssl/${DOMAIN}.key \
|
||||
@@ -1728,6 +1756,13 @@ deploy_acme_buypass() {
|
||||
# 申请证书
|
||||
echo ""
|
||||
print_info "正在申请 Buypass 证书..."
|
||||
|
||||
# 再次确认acme.sh存在
|
||||
if [[ ! -f ~/.acme.sh/acme.sh ]]; then
|
||||
print_error "acme.sh文件不存在: ~/.acme.sh/acme.sh"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ~/.acme.sh/acme.sh --server buypass --issue -d "$DOMAIN" --nginx; then
|
||||
print_success "证书申请成功"
|
||||
else
|
||||
@@ -1738,6 +1773,13 @@ deploy_acme_buypass() {
|
||||
# 安装证书
|
||||
echo ""
|
||||
print_info "正在安装证书到Nginx..."
|
||||
|
||||
# 再次确认acme.sh存在
|
||||
if [[ ! -f ~/.acme.sh/acme.sh ]]; then
|
||||
print_error "acme.sh文件不存在: ~/.acme.sh/acme.sh"
|
||||
return 1
|
||||
fi
|
||||
|
||||
mkdir -p /etc/nginx/ssl
|
||||
if ~/.acme.sh/acme.sh --install-cert -d "$DOMAIN" \
|
||||
--key-file /etc/nginx/ssl/${DOMAIN}.key \
|
||||
@@ -2456,11 +2498,18 @@ configure_nginx_https() {
|
||||
mkdir -p ${NGINX_CONF_DIR}
|
||||
fi
|
||||
|
||||
# 根据HTTPS端口生成正确的重定向URL
|
||||
if [[ "$HTTPS_PORT" == "443" ]]; then
|
||||
REDIRECT_URL="https://\$server_name\$request_uri"
|
||||
else
|
||||
REDIRECT_URL="https://\$server_name:${HTTPS_PORT}\$request_uri"
|
||||
fi
|
||||
|
||||
cat > ${NGINX_CONF_DIR}/${PROJECT_NAME}.conf << EOF
|
||||
server {
|
||||
listen ${HTTP_PORT};
|
||||
server_name ${DOMAIN};
|
||||
return 301 https://\$server_name:\${HTTPS_PORT}\$request_uri;
|
||||
return 301 ${REDIRECT_URL};
|
||||
}
|
||||
|
||||
server {
|
||||
|
||||
Reference in New Issue
Block a user