准备部署
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
# 青叶前端容器 Nginx 配置(提供 SPA 静态文件)
|
||||
# 仅负责静态资源与前端路由回退;API / WebSocket / 上传文件由「宿主机 Nginx」转发到后端。
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# gzip 压缩
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_types text/plain text/css application/json application/javascript application/xml text/xml application/xml+rss text/javascript image/svg+xml;
|
||||
|
||||
# SPA 路由回退:Vue Router 使用 createWebHistory(HTML5 history 模式),
|
||||
# 刷新 /chat、/moments 等前端路由时需回退到 index.html
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# 静态资源长缓存(Vite 产物带 hash 文件名,可安全强缓存)
|
||||
location ~* \.(?:js|css|woff2?|ttf|eot|png|jpg|jpeg|gif|ico|svg)$ {
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
access_log off;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user