fix(nginx): 变量 proxy_pass 须 rewrite 去掉 /admin,否则静态资源回退 index.html
Made-with: Cursor
This commit is contained in:
@@ -15,5 +15,5 @@
|
||||
2. **确认 dist 完整**:`deploy/admin/dist/assets/` 下须有与 `index.html` 中 `<script type="module">` 引用**同名**的哈希文件;发版后应**整目录**替换 `dist`(勿只拷 `index.html`)。
|
||||
3. **本地重建**:在项目根按 `pull-and-restart.sh` 方式在 `admin/` 执行 `npm run build`,`vite.config` 中 `base` 须为 `'/admin/'`。
|
||||
4. **勿用旧版 `nginx/admin.conf`**:若曾把仅含 `location /` 的旧配置拷到服务器,会导致 `/assets/*.js` 全部变成 `index.html`(约 640B、MIME 错)。请以 **`deploy/admin/default.conf`** 或 **`admin/nginx.conf`** 为准,并 **`docker compose restart admin nginx`**。
|
||||
5. **若出现 500**:外层 `yuheng.docker.conf.tpl` 仅用 **`location /admin/`** 反代即可(勿对 `/admin/assets/` 再写 `rewrite` + 变量 `proxy_pass`,部分环境会 **500**);白屏仍以 **内层** `deploy/admin/default.conf` 的 `^~ /assets/` 为准。
|
||||
5. **变量 `proxy_pass` 与路径**:外层 `yh_nginx` 对 **`location /admin/`** 须 **`rewrite ^/admin/(.*)$ /$1 break`** 再 **`proxy_pass http://$upstream_admin:80`**(无 URI 后缀)。否则 Nginx 会把 **`/admin/assets/...` 原样**传到 admin,内层只认 **`/assets/...`** → 全部回退 `index.html`(网络面板里 JS/CSS 与 document 同几百字节)。**`/api/`** 不要用 rewrite(API 需要完整 `/api/...`)。
|
||||
6. **`restart.sh` 构建 admin** 已与 **`pull-and-restart.sh` 一致**(挂载**项目根**到容器,否则 `@yh-web` 无法解析)。发版后脚本会执行 **`scripts/verify-admin-dist.sh`**:若 `index.html` 引用的 chunk 在 `dist/assets/` 中缺失或过小(几百字节),会直接报错退出,避免白屏上线。
|
||||
|
||||
Reference in New Issue
Block a user