54 lines
1.6 KiB
Plaintext
54 lines
1.6 KiB
Plaintext
# 管理员端 Nginx 配置 - dda.gaowenbu.cn
|
||
# 用途:服务 web-admin 前端静态文件 + 反向代理 /api 和 /uploads 到后端
|
||
|
||
server {
|
||
listen 80;
|
||
server_name dda.gaowenbu.cn;
|
||
|
||
# 管理员端前端静态文件
|
||
root /var/www/order-flow/web-admin/dist;
|
||
index index.html;
|
||
|
||
# 前端路由 history 模式支持
|
||
location / {
|
||
try_files $uri $uri/ /index.html;
|
||
}
|
||
|
||
# WebSocket 反向代理
|
||
location /ws/ {
|
||
proxy_pass http://127.0.0.1:8000;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Upgrade $http_upgrade;
|
||
proxy_set_header Connection "upgrade";
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
proxy_set_header X-Forwarded-Proto $scheme;
|
||
proxy_read_timeout 86400s;
|
||
proxy_send_timeout 86400s;
|
||
}
|
||
|
||
# API 反向代理到后端 FastAPI 服务
|
||
location /api/ {
|
||
proxy_pass http://127.0.0.1:8000;
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
proxy_set_header X-Forwarded-Proto $scheme;
|
||
proxy_read_timeout 300s;
|
||
proxy_connect_timeout 60s;
|
||
}
|
||
|
||
# 本地上传文件代理(开发环境用,生产环境建议使用 OSS)
|
||
location /uploads/ {
|
||
proxy_pass http://127.0.0.1:8000;
|
||
proxy_set_header Host $host;
|
||
}
|
||
|
||
# 静态资源缓存
|
||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||
expires 7d;
|
||
add_header Cache-Control "public, immutable";
|
||
}
|
||
}
|