feat(deploy): 发布移动网页并独立续期 API 证书
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
0a7c28c978
commit
652cf6df1a
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
物品详情支持编辑、移位、收藏及照片。拍照和相册统一进入裁剪,输入上限 30 MiB,输出最长边 1440 像素、上限 5 MiB。上传后显示服务端的缩略图,点开读取原图。照片写入、删除和清理走现有物品接口。能否直接调起摄像头取决于浏览器和设备。
|
||||
|
||||
公网入口为 [m-atlas.tutudog.com](https://m-atlas.tutudog.com)。 [发布与回退](../../deploy/public/README.md#h5-移动网页)
|
||||
|
||||
## 本地启动
|
||||
|
||||
使用 Node.js 24。工作目录为仓库根目录。
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# 见物公网预览
|
||||
|
||||
`api-atlas.tutudog.com` 为 iOS 提供 HTTPS。完整路径为公网 Nginx → 两条 FRP STCP → 工作 Mac 的 SSD VM → Kubernetes Service。`/api/` 到网关,`/auth/realms/item-atlas/` 与 `/auth/resources/` 到 Keycloak。身份服务用 Keycloak 的生产启动模式和固定 issuer。账号由内部后台创建,开放注册关闭。
|
||||
`api-atlas.tutudog.com` 为原生客户端提供 HTTPS。完整路径为公网 Nginx → 两条 FRP STCP → 工作 Mac 的 SSD VM → Kubernetes Service。`/api/` 到网关,`/auth/realms/item-atlas/` 与 `/auth/resources/` 到 Keycloak。身份服务用 Keycloak 的生产启动模式和固定 issuer。账号由内部后台创建,开放注册关闭。
|
||||
|
||||
## 应用和数据
|
||||
|
||||
|
|
@ -65,6 +65,15 @@ kubectl -n item-atlas-public logs deployment/atlas-public-frpc --tail=20
|
|||
|
||||
工作 Mac 需要挂载 SSD 并运行 Linux VM,集群会启动 FRP 客户端并重连。通常检查顺序是 DNS、TLS、Nginx、STCP、Service 与应用。检查应用版本用 `helm history item-atlas -n item-atlas-public`,回退前先核对数据库迁移兼容性。需要关闭公网预览时停用该域名的独立 Nginx 站点。数据库和私有桶有独立备份流程。
|
||||
|
||||
### API 证书
|
||||
|
||||
公网 API 使用独立的 Certbot HTTP-01 证书。首次接入先配置 HTTP 站点,让挑战路径使用 Nginx 配置挂载目录的 `.acme-api`。已有 HTTPS 站点时可先保留原证书。申请成功后将 `install-api-certificate.sh` 安装为 `/opt/item-atlas-api-cert/install-certificate.sh` 并运行,再切换 `nginx.conf.template` 所示的专用证书路径。检查配置、重载并启用 `item-atlas-api-cert-renew.timer`。
|
||||
|
||||
```sh
|
||||
certbot renew --cert-name api-atlas.tutudog.com --dry-run
|
||||
systemctl list-timers item-atlas-api-cert-renew.timer
|
||||
```
|
||||
|
||||
## PC 工作台
|
||||
|
||||
`pc-atlas.tutudog.com` 的页面及静态资源经独立的 `jianwu-public-pc` STCP 到 PC 容器。同源 `/api/` 复用网关的 STCP 通道。会话请求使用现有的限流区,管理 API 路径在 PC 入口返回 404。PC 前端和 FRP 客户端使用独立 Deployment,前端更新时可以保留已注册的通道。
|
||||
|
|
@ -91,3 +100,21 @@ curl -fsS https://pc-atlas.tutudog.com/floor-plan
|
|||
```
|
||||
|
||||
验收包括深层页面刷新、原生账号登录、物品搜索和平面图读取。PC 版本用 `helm history item-atlas-pc -n item-atlas-public` 查看。后续镜像更新可回退到上一份包含 FRP 的 PC 修订,并复验页面和 API。
|
||||
|
||||
## H5 移动网页
|
||||
|
||||
`m-atlas.tutudog.com` 通过 `jianwu-public-h5` STCP 服务移动网页,复用原网关 STCP 提供同源 `/api/`。H5 与 PC 使用相同的静态站点 chart,镜像、Secret、FRP 客户端和 Helm release 各自独立。
|
||||
|
||||
1. 按 [H5 构建说明](../../apps/h5/README.md#构建镜像) 生成并加载 ARM64 镜像。渲染 `h5-frpc.toml.template`,用独立 STCP 密钥创建 `atlas-h5-frpc`。
|
||||
2. 在入口云机渲染 `h5-visitor.toml.template`,放在 `/opt/item-atlas-h5/frpc.toml`。安装 `item-atlas-h5-frpc.service`,visitor 仅监听 Nginx 私有网桥的 18793 端口。
|
||||
3. 渲染 `h5-nginx.conf.template`。首次签发时,先加载带挑战路径的 HTTP 站点和 `.acme-h5` webroot,再设置 A 记录和签发独立证书。将 `install-h5-certificate.sh` 安装为 `/opt/item-atlas-h5/install-certificate.sh`,运行一次后启用 HTTPS 站点和 `item-atlas-h5-cert-renew.timer`。每次改 Nginx 后先运行 `nginx -t`,通过再重载。
|
||||
|
||||
```sh
|
||||
helm upgrade --install item-atlas-h5 deploy/helm/item-atlas-pc -n item-atlas-public \
|
||||
-f deploy/public/h5-values.yaml --set-string image="$ATLAS_H5_IMAGE" \
|
||||
--atomic --wait --timeout 3m
|
||||
certbot renew --cert-name m-atlas.tutudog.com --dry-run
|
||||
curl -fsS https://m-atlas.tutudog.com/healthz
|
||||
```
|
||||
|
||||
验收时从公网手机视口走登录、手动录入和找物,照片要查缩略图与删除。匿名业务 API 应返回 401,管理路径应返回 404。后续 H5 更新可按 `helm history item-atlas-h5 -n item-atlas-public` 查历史并回滚到先前成功的修订,复验页面和 API。
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
serverAddr = "ATLAS_FRPS_HOST"
|
||||
serverPort = 7000
|
||||
auth.method = "token"
|
||||
auth.token = "ATLAS_FRPS_TOKEN"
|
||||
transport.tls.enable = true
|
||||
|
||||
[[proxies]]
|
||||
name = "jianwu-public-h5"
|
||||
type = "stcp"
|
||||
secretKey = "ATLAS_H5_STCP_KEY"
|
||||
localIP = "item-atlas-h5"
|
||||
localPort = 8080
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
server {
|
||||
listen 80;
|
||||
server_name m-atlas.tutudog.com;
|
||||
location ^~ /.well-known/acme-challenge/ {
|
||||
root /etc/nginx/conf.d/.acme-h5;
|
||||
try_files $uri =404;
|
||||
}
|
||||
location / { return 308 https://m-atlas.tutudog.com$request_uri; }
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name m-atlas.tutudog.com;
|
||||
ssl_certificate ATLAS_H5_CERT_DIR/fullchain.pem;
|
||||
ssl_certificate_key ATLAS_H5_CERT_DIR/privkey.pem;
|
||||
client_max_body_size 6m;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header X-Forwarded-Port 443;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_connect_timeout 5s;
|
||||
proxy_read_timeout 90s;
|
||||
|
||||
gzip on;
|
||||
gzip_types application/javascript text/css;
|
||||
|
||||
location = /api/admin { return 404; }
|
||||
location ^~ /api/admin/ { return 404; }
|
||||
location ^~ /api/session/ {
|
||||
client_max_body_size 4k;
|
||||
limit_req zone=atlas_native_session burst=10 nodelay;
|
||||
limit_req_status 429;
|
||||
proxy_pass http://ATLAS_VISITOR_API;
|
||||
}
|
||||
location ^~ /api/ {
|
||||
proxy_pass http://ATLAS_VISITOR_API;
|
||||
}
|
||||
location / {
|
||||
proxy_pass http://ATLAS_VISITOR_H5;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
image: item-atlas-h5:0.1.0
|
||||
frp:
|
||||
enabled: true
|
||||
secretName: atlas-h5-frpc
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
serverAddr = "ATLAS_FRPS_HOST"
|
||||
serverPort = 7000
|
||||
auth.method = "token"
|
||||
auth.token = "ATLAS_FRPS_TOKEN"
|
||||
transport.tls.enable = true
|
||||
|
||||
[[visitors]]
|
||||
name = "jianwu-public-h5-visitor"
|
||||
type = "stcp"
|
||||
serverName = "jianwu-public-h5"
|
||||
secretKey = "ATLAS_H5_STCP_KEY"
|
||||
bindAddr = "ATLAS_VISITOR_BIND_ADDR"
|
||||
bindPort = 18793
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
umask 077
|
||||
|
||||
lineage=/etc/letsencrypt/live/api-atlas.tutudog.com
|
||||
if [ -n "${RENEWED_LINEAGE:-}" ] && [ "$RENEWED_LINEAGE" != "$lineage" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ssl_root=${ATLAS_EDGE_SSL_ROOT:-/home/dongjf/dongjf-ng/ssl}
|
||||
nginx=${ATLAS_EDGE_NGINX:-dongjf-nginx}
|
||||
target="$ssl_root/api-atlas.tutudog.com"
|
||||
install -d -m 0700 "$target"
|
||||
cert_key=$(openssl x509 -in "$lineage/fullchain.pem" -pubkey -noout | openssl sha256)
|
||||
private_key=$(openssl pkey -in "$lineage/privkey.pem" -pubout | openssl sha256)
|
||||
test "$cert_key" = "$private_key"
|
||||
openssl x509 -in "$lineage/fullchain.pem" -checkend 86400 -noout
|
||||
|
||||
release=$(mktemp -d "$target/cert.XXXXXX")
|
||||
install -m 0644 "$lineage/fullchain.pem" "$release/fullchain.pem"
|
||||
install -m 0600 "$lineage/privkey.pem" "$release/privkey.pem"
|
||||
previous=$(readlink "$target/current" || true)
|
||||
ln -s "$(basename "$release")" "$target/.current.$$"
|
||||
mv -Tf "$target/.current.$$" "$target/current"
|
||||
|
||||
if docker exec "$nginx" nginx -t && docker exec "$nginx" nginx -s reload; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n "$previous" ]; then
|
||||
ln -s "$previous" "$target/.current.$$"
|
||||
mv -Tf "$target/.current.$$" "$target/current"
|
||||
else
|
||||
mv "$target/current" "$target/failed.$$"
|
||||
fi
|
||||
exit 1
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
umask 077
|
||||
|
||||
lineage=/etc/letsencrypt/live/m-atlas.tutudog.com
|
||||
if [ -n "${RENEWED_LINEAGE:-}" ] && [ "$RENEWED_LINEAGE" != "$lineage" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ssl_root=${ATLAS_EDGE_SSL_ROOT:-/home/dongjf/dongjf-ng/ssl}
|
||||
nginx=${ATLAS_EDGE_NGINX:-dongjf-nginx}
|
||||
target="$ssl_root/m-atlas.tutudog.com"
|
||||
install -d -m 0700 "$target"
|
||||
cert_key=$(openssl x509 -in "$lineage/fullchain.pem" -pubkey -noout | openssl sha256)
|
||||
private_key=$(openssl pkey -in "$lineage/privkey.pem" -pubout | openssl sha256)
|
||||
test "$cert_key" = "$private_key"
|
||||
openssl x509 -in "$lineage/fullchain.pem" -checkend 86400 -noout
|
||||
|
||||
release=$(mktemp -d "$target/cert.XXXXXX")
|
||||
install -m 0644 "$lineage/fullchain.pem" "$release/fullchain.pem"
|
||||
install -m 0600 "$lineage/privkey.pem" "$release/privkey.pem"
|
||||
previous=$(readlink "$target/current" || true)
|
||||
ln -s "$(basename "$release")" "$target/.current.$$"
|
||||
mv -Tf "$target/.current.$$" "$target/current"
|
||||
|
||||
if docker exec "$nginx" nginx -t && docker exec "$nginx" nginx -s reload; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n "$previous" ]; then
|
||||
ln -s "$previous" "$target/.current.$$"
|
||||
mv -Tf "$target/.current.$$" "$target/current"
|
||||
else
|
||||
mv "$target/current" "$target/failed.$$"
|
||||
fi
|
||||
exit 1
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
[Unit]
|
||||
Description=Renew the Item Atlas public API certificate
|
||||
Wants=network-online.target
|
||||
After=network-online.target docker.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/certbot renew --quiet --cert-name api-atlas.tutudog.com --deploy-hook /opt/item-atlas-api-cert/install-certificate.sh
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=Check the Item Atlas public API certificate twice a day
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*-*-* 04,16:20:00
|
||||
RandomizedDelaySec=20m
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
[Unit]
|
||||
Description=Renew the Item Atlas mobile site certificate
|
||||
Wants=network-online.target
|
||||
After=network-online.target docker.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/certbot renew --quiet --cert-name m-atlas.tutudog.com --deploy-hook /opt/item-atlas-h5/install-certificate.sh
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=Check the Item Atlas mobile site certificate twice a day
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*-*-* 03,15:20:00
|
||||
RandomizedDelaySec=20m
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
[Unit]
|
||||
Description=Item Atlas mobile web FRP visitor
|
||||
Wants=network-online.target
|
||||
After=network-online.target docker.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/opt/localollama-relay/frpc -c /opt/item-atlas-h5/h5-visitor.toml
|
||||
Restart=on-failure
|
||||
RestartSec=4s
|
||||
NoNewPrivileges=true
|
||||
ProtectSystem=strict
|
||||
ProtectHome=true
|
||||
PrivateTmp=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -3,14 +3,18 @@ limit_req_zone $binary_remote_addr zone=atlas_native_session:1m rate=30r/m;
|
|||
server {
|
||||
listen 80;
|
||||
server_name api-atlas.tutudog.com;
|
||||
return 308 https://api-atlas.tutudog.com$request_uri;
|
||||
location ^~ /.well-known/acme-challenge/ {
|
||||
root /etc/nginx/conf.d/.acme-api;
|
||||
try_files $uri =404;
|
||||
}
|
||||
location / { return 308 https://api-atlas.tutudog.com$request_uri; }
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name api-atlas.tutudog.com;
|
||||
ssl_certificate /etc/nginx/ssl/tutudog.com/fullchain.pem;
|
||||
ssl_certificate_key /etc/nginx/ssl/tutudog.com/privkey.pem;
|
||||
ssl_certificate /etc/nginx/ssl/api-atlas.tutudog.com/current/fullchain.pem;
|
||||
ssl_certificate_key /etc/nginx/ssl/api-atlas.tutudog.com/current/privkey.pem;
|
||||
client_max_body_size 6m;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
|
|
|
|||
|
|
@ -44,16 +44,16 @@ Kubernetes 的控制面和应用在同一虚拟机内。Helm 管理应用和可
|
|||
|
||||
## 公网入口和域名
|
||||
|
||||
公网 Nginx 负责证书和 HTTPS,保留 Host 和转发协议。三个 frp visitor 在云端私有网桥监听,分别通过 STCP 到集群中的 Gateway、Keycloak 和 PC Service。PC 网页的同源 `/api/` 复用网关通道。数据库、监控和 Kubernetes 管理端口留在内网。见物的模型调用走家庭私网。 [公网部署](../../deploy/public/README.md) · [frp STCP](https://gofrp.org/en/docs/examples/stcp/)
|
||||
公网 Nginx 负责证书和 HTTPS,保留 Host 和转发协议。四个 frp visitor 在云端私有网桥监听,分别通过 STCP 到集群中的 Gateway、Keycloak、PC 和 H5 Service。两个网页入口的同源 `/api/` 复用网关通道。数据库、监控和 Kubernetes 管理端口留在内网。见物的模型调用走家庭私网。 [公网部署](../../deploy/public/README.md) · [frp STCP](https://gofrp.org/en/docs/examples/stcp/)
|
||||
|
||||
子域名统一采用 `用途-产品名`。移动网页用 `m`,PC 网页用 `pc`。API 和 PC 网页已开通公网 HTTPS。 [公网连通性验收](identity-and-media.md#ios-公网连通性验收)
|
||||
子域名统一采用 `用途-产品名`。移动网页用 `m`,PC 网页用 `pc`。API、PC 和移动网页已开通公网 HTTPS,各自续期。 [公网连通性验收](identity-and-media.md#ios-公网连通性验收)
|
||||
|
||||
| 域名 | 指向 |
|
||||
| --- | --- |
|
||||
| `pc-atlas.tutudog.com` | PC 网页,独立证书和续期定时器 |
|
||||
| `m-atlas.tutudog.com` | 移动网页(H5) |
|
||||
| `admin-atlas.tutudog.com` | 管理后台,使用管理员身份和访问限制 |
|
||||
| `api-atlas.tutudog.com` | 项目专用 HTTPS 入口,`/api/` 到网关,`/auth/` 到正式身份服务 |
|
||||
| `m-atlas.tutudog.com` | 移动网页(H5),独立证书和续期定时器 |
|
||||
| `admin-atlas.tutudog.com` | 管理后台规划域名,目前通过内部入口使用 |
|
||||
| `api-atlas.tutudog.com` | 项目专用 HTTPS 入口,独立证书和续期定时器。`/api/` 到网关,`/auth/` 到正式身份服务 |
|
||||
|
||||
已有 frp 足够用于首版演示。5 Mbps 约为每秒 0.625 MB 的理论上限。前端资源压缩和缓存,照片以缩略图为先,上传按大小和并发限制。
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue