40 lines
1.4 KiB
Plaintext
40 lines
1.4 KiB
Plaintext
|
|
server {
|
|||
|
|
listen 80;
|
|||
|
|
server_name _;
|
|||
|
|
charset utf-8;
|
|||
|
|
|
|||
|
|
# 内网机 = /usr/share/nginx/inside,外网机 = /usr/share/nginx/outside(见 .env)
|
|||
|
|
root ${SFILE_SITE_ROOT};
|
|||
|
|
index index.html;
|
|||
|
|
|
|||
|
|
# 与后端 multipart 上限(500MB)保持一致,改这里要同步改 application.yml
|
|||
|
|
client_max_body_size 500m;
|
|||
|
|
|
|||
|
|
# /api/xxx -> 后端 /xxx(去掉 /api 前缀,与前端构建时的 VITE_API_URL=/api 对应)
|
|||
|
|
location /api/ {
|
|||
|
|
proxy_pass http://${SFILE_APP_UPSTREAM}:8080/;
|
|||
|
|
proxy_http_version 1.1;
|
|||
|
|
# 必须保留端口($http_host):后端 getRootDomain 对「无端口的 IP/localhost」会抛
|
|||
|
|
# IllegalStateException,导致登录成功回调 500。改成 $host 就会复现这个坑
|
|||
|
|
proxy_set_header Host $http_host;
|
|||
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|||
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|||
|
|
proxy_set_header Upgrade $http_upgrade;
|
|||
|
|
proxy_set_header Connection "upgrade";
|
|||
|
|
proxy_read_timeout 600s;
|
|||
|
|
proxy_send_timeout 600s;
|
|||
|
|
# 大文件上传不在 nginx 侧缓冲,直接流给后端
|
|||
|
|
proxy_request_buffering off;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# SPA:hash 路由,静态资源找不到时回落 index.html
|
|||
|
|
location / {
|
|||
|
|
try_files $uri $uri/ /index.html;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
location ~* \.(js|mjs|css|woff2?|ttf|png|jpe?g|gif|svg|ico)$ {
|
|||
|
|
expires 7d;
|
|||
|
|
access_log off;
|
|||
|
|
}
|
|||
|
|
}
|