update: update nginx config to add frontend build assets
This commit is contained in:
@@ -16,6 +16,28 @@ server {
|
||||
# 指定 Docker 内置 DNS 解析器,并设置 30 秒缓存
|
||||
resolver 127.0.0.11 valid=30s ipv6=off;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html; # 前端静态文件存放在容器中的路径
|
||||
index index.html index.htm;
|
||||
|
||||
# 核心:支持 SPA 路由(前端 React Router / Vue Router 刷新不报 404)
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# (可选)针对静态文件资源加长期缓存优化
|
||||
# location ~* \.(?:css|js|jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|woff|woff2)$ {
|
||||
# root /usr/share/nginx/html;
|
||||
# expires 2h; # 前端静态缓存2小时
|
||||
# add_header Cache-Control "public, no-transform";
|
||||
# }
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://backend:8000/api/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
# =========================================================================
|
||||
# 1. RustFS 对象存储服务转发 (/storage/)
|
||||
# =========================================================================
|
||||
|
||||
@@ -8,6 +8,7 @@ services:
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./default.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
- ./frontend/build/client:/usr/share/nginx/html:ro
|
||||
depends_on:
|
||||
- backend
|
||||
|
||||
|
||||
Reference in New Issue
Block a user