28 lines
876 B
Nginx Configuration File
28 lines
876 B
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name localhost;
|
|
|
|
# Vue 静态文件
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# ========== 后端 API 代理 ==========
|
|
# 精确匹配所有后端 API 路径,转发到 FastAPI
|
|
location ~ ^/(login|register|updatePassword|admin|student|major|clazz|course|grade|notice|studentCourse|files) {
|
|
proxy_pass http://backend:9090;
|
|
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;
|
|
}
|
|
|
|
# ========== SPA 前端路由 ==========
|
|
# 先匹配静态文件,找不到则回退到 index.html(交由 Vue Router 处理)
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# 文件上传大小限制
|
|
client_max_body_size 50m;
|
|
}
|