sync: d8d-dev 技能更新 — NPM 代理配置 + MinIO 外网地址注入
- phase-00-setup.md: 步骤 4.5 NPM block_exploits/WebSocket, 步骤 4.8 MinIO 外网地址 - platform-nextjs.md: §7 NPM 代理配置, §8 MinIO 外网地址配置 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -177,6 +177,26 @@
|
||||
- 此步骤创建的 .env.local 不应提交到 git(应在 .gitignore 中排除)
|
||||
- 更新 pipeline-context.md 记录注入状态
|
||||
|
||||
4.8. **MinIO 外网地址注入(⛔ 强制)**
|
||||
|
||||
检测容器环境变量 `MINIO_HOST`,将外网地址注入到 `.env` 中的 `S3_PUBLIC_URL`:
|
||||
|
||||
a. 检测 MINIO_HOST:
|
||||
```bash
|
||||
echo $MINIO_HOST
|
||||
```
|
||||
b. 探测 HTTPS 是否可用:
|
||||
```bash
|
||||
curl -sf --max-time 5 https://$MINIO_HOST/minio/health/live && echo "HTTPS" || echo "NO-HTTPS"
|
||||
```
|
||||
c. 注入到 `.env`(⚠️ 注意 K8S ingress 会将 HTTP 升级为 HTTPS,必须使用 HTTPS):
|
||||
```
|
||||
S3_PUBLIC_URL="https://{MINIO_HOST}"
|
||||
```
|
||||
d. 代码中对外暴露的 URL(presigned URL、封面图 URL)必须使用 `S3_PUBLIC_URL`
|
||||
e. 内部连接(S3Client endpoint)保持 `S3_ENDPOINT`(localhost:9000)
|
||||
f. 详见 `reference/platform-nextjs.md` §8
|
||||
|
||||
5. **初始化管道状态**
|
||||
- 创建 `{implementation_artifacts}/pipeline-state.yaml`:
|
||||
```yaml
|
||||
|
||||
@@ -230,3 +230,33 @@ NPM 代理主机默认配置会阻断 WebSocket,导致:
|
||||
### 验证
|
||||
|
||||
`get_proxy_host` 确认:`block_exploits: false` + `allow_websocket_upgrade: true`
|
||||
|
||||
---
|
||||
|
||||
## 8. MinIO 外网地址配置(⛔ 强制)
|
||||
|
||||
### 问题描述
|
||||
|
||||
`S3_ENDPOINT` 默认为 `http://localhost:9000`(容器内部连接)。但对外暴露的 URL(presigned URL、封面图 URL)
|
||||
如果使用 `localhost:9000`,外网用户无法访问。
|
||||
|
||||
容器环境提供 `MINIO_HOST` 环境变量(外网 MinIO 域名),需要注入为 `S3_PUBLIC_URL`。
|
||||
|
||||
### 关键区分
|
||||
|
||||
| 变量 | 用途 | 值 |
|
||||
|------|------|------|
|
||||
| `S3_ENDPOINT` | S3Client 内部连接 | `http://localhost:9000` |
|
||||
| `S3_PUBLIC_URL` | 对外暴露的 URL(presigned、封面) | `https://{MINIO_HOST}` |
|
||||
|
||||
### 代码规则
|
||||
|
||||
- **`getDownloadUrl()`**:返回内部 presigned URL(worker 下载用)
|
||||
- **`getPublicDownloadUrl()`**:返回外网 presigned URL(stream 路由用,替换域名)
|
||||
- **`uploadFile()` 返回值**:使用 `S3_PUBLIC_URL`(公开访问 URL)
|
||||
- **worker 中的封面 URL**:使用 `S3_PUBLIC_URL`
|
||||
|
||||
### ⚠️ HTTPS 注意
|
||||
|
||||
K8S ingress 会将 HTTP 升级为 HTTPS。`S3_PUBLIC_URL` 必须使用 `https://`,
|
||||
否则 presigned URL 签名会因重定向而失效。
|
||||
|
||||
Reference in New Issue
Block a user