Fix Caddy install method and add deployment docs
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
52
deploy/README.md
Normal file
52
deploy/README.md
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# Nomadro 部署说明
|
||||||
|
|
||||||
|
## 服务器信息
|
||||||
|
|
||||||
|
- 主机: `107.173.30.245`
|
||||||
|
- 代码目录: `/var/www/nomadro.com`
|
||||||
|
- 应用端口: `4003`(仅本机)
|
||||||
|
- 域名: `nomadro.com` / `www.nomadro.com` → Caddy 反代
|
||||||
|
|
||||||
|
## 不影响现有业务
|
||||||
|
|
||||||
|
- nginx 仍在 **23794** 端口服务 `specials.nomadro.live`(v2ray-agent),未改动
|
||||||
|
- sing-box 未改动
|
||||||
|
- Caddy 仅占用 **80/443**,专用于 nomadro.com
|
||||||
|
|
||||||
|
## DNS 配置(必须)
|
||||||
|
|
||||||
|
将域名 A 记录指向服务器 IP:
|
||||||
|
|
||||||
|
```
|
||||||
|
nomadro.com A 107.173.30.245
|
||||||
|
www.nomadro.com A 107.173.30.245
|
||||||
|
```
|
||||||
|
|
||||||
|
若使用 Cloudflare,需关闭代理(灰云)或配置 Origin 指向该 IP,否则 Caddy 无法自动签发 HTTPS 证书。
|
||||||
|
|
||||||
|
## 首次部署
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ssh root@107.173.30.245
|
||||||
|
export GIT_PASS='你的密码'
|
||||||
|
export GIT_USER='eric'
|
||||||
|
git clone -b test https://eric:${GIT_PASS}@gitea.dsx2020.com/eric/gitlab-instance-0a899031_nomadro.git /var/www/nomadro.com
|
||||||
|
cd /var/www/nomadro.com
|
||||||
|
bash deploy/setup-server.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## 日常更新
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ssh root@107.173.30.245
|
||||||
|
cd /var/www/nomadro.com
|
||||||
|
bash deploy/deploy.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## 服务管理
|
||||||
|
|
||||||
|
```bash
|
||||||
|
systemctl status nomadro caddy nginx
|
||||||
|
journalctl -u nomadro -f
|
||||||
|
journalctl -u caddy -f
|
||||||
|
```
|
||||||
@@ -23,14 +23,15 @@ fi
|
|||||||
|
|
||||||
echo "==> Install Caddy"
|
echo "==> Install Caddy"
|
||||||
if ! command -v caddy >/dev/null 2>&1; then
|
if ! command -v caddy >/dev/null 2>&1; then
|
||||||
apt-get install -y debian-keyring debian-archive-keyring apt-transport-https curl
|
apt-get install -y debian-keyring debian-archive-keyring apt-transport-https curl gnupg
|
||||||
curl -1sLf 'https://dl.caddyserver.com/api/download/installer/deb/caddy-stable/caddy-stable.list' \
|
curl -fsSL 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' \
|
||||||
|
| gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
|
||||||
|
curl -fsSL 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' \
|
||||||
| tee /etc/apt/sources.list.d/caddy-stable.list
|
| tee /etc/apt/sources.list.d/caddy-stable.list
|
||||||
curl -1sLf 'https://dl.caddyserver.com/api/download/installer/deb/caddy-stable/caddy-stable-archive-keyring.gpg' \
|
|
||||||
| tee /usr/share/keyrings/caddy-stable-archive-keyring.gpg >/dev/null
|
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y caddy
|
apt-get install -y caddy
|
||||||
fi
|
fi
|
||||||
|
mkdir -p /etc/caddy
|
||||||
|
|
||||||
echo "==> Clone or update app"
|
echo "==> Clone or update app"
|
||||||
mkdir -p /var/www
|
mkdir -p /var/www
|
||||||
@@ -49,19 +50,7 @@ pnpm install --frozen-lockfile
|
|||||||
pnpm build
|
pnpm build
|
||||||
|
|
||||||
echo "==> Configure Caddy (only nomadro.com, keep nginx untouched)"
|
echo "==> Configure Caddy (only nomadro.com, keep nginx untouched)"
|
||||||
CADDY_MAIN="/etc/caddy/Caddyfile"
|
cp "$APP_DIR/deploy/Caddyfile" /etc/caddy/Caddyfile
|
||||||
SNIPPET="# nomadro.com - managed by nomadro deploy"
|
|
||||||
if [ -f "$CADDY_MAIN" ] && grep -q "nomadro.com" "$CADDY_MAIN"; then
|
|
||||||
echo "Caddy nomadro.com block already exists"
|
|
||||||
else
|
|
||||||
if [ ! -f "$CADDY_MAIN" ] || [ ! -s "$CADDY_MAIN" ]; then
|
|
||||||
cp "$APP_DIR/deploy/Caddyfile" "$CADDY_MAIN"
|
|
||||||
else
|
|
||||||
echo "" >> "$CADDY_MAIN"
|
|
||||||
echo "$SNIPPET" >> "$CADDY_MAIN"
|
|
||||||
cat "$APP_DIR/deploy/Caddyfile" >> "$CADDY_MAIN"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
caddy validate --config "$CADDY_MAIN"
|
caddy validate --config "$CADDY_MAIN"
|
||||||
systemctl enable caddy
|
systemctl enable caddy
|
||||||
systemctl reload caddy || systemctl restart caddy
|
systemctl reload caddy || systemctl restart caddy
|
||||||
|
|||||||
Reference in New Issue
Block a user