Files
iotlcm/docker/nginx.conf
T
MiFaZhan eeeb6572ba fix: nginx 在 /docs/ 下服务产物,修复白屏
VitePress 配置 base: '/docs/',构建出的 HTML 里资源引用是绝对路径 /docs/assets/xxx;
而 dist 目录是平铺的(index.html、assets/ 直接在根)。原 nginx.conf 从根路径服务,
/docs/assets/* 全部 404 → 页面能打开但 JS/CSS 加载失败,白屏、点击无反应。

改为用 alias 把 /docs/ 前缀剥掉再落到产物目录,并加 / -> /docs/ 的 302,
避免直接访问根路径白屏。

实测(本地构建镜像后):/docs/ 200、/docs/manual/web/ 200、/docs/openapi/ 200、
核心 CSS 资源 200;/ 返回 302。
2026-10-30 13:11:58 +08:00

26 lines
764 B
Nginx Configuration File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# VitePress 配置 base: '/docs/',构建产物里的资源引用是绝对路径 /docs/assets/xxx,
# 而 dist 目录是平铺的(index.html、assets/ 直接在根)。
# 因此必须在 /docs/ 路径下提供服务,用 alias 把前缀剥掉再落到产物目录,
# 否则页面能返回 200 但 JS/CSS 全部 404 → 白屏。
location /docs/ {
alias /usr/share/nginx/html/;
try_files $uri $uri.html $uri/ $uri/index.html =404;
}
# 根路径跳到文档入口,避免访问 / 时白屏
location = / {
return 302 /docs/;
}
location / {
try_files $uri $uri.html $uri/ =404;
}
}