init
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name 150.158.236.152; # 替换为你的服务器 IP/域名
|
||||
client_max_body_size 100M; # 全局生效的文件上传大小限制
|
||||
|
||||
# 日志配置
|
||||
access_log /var/log/nginx/front-access.log main;
|
||||
error_log /var/log/nginx/front-error.log warn;
|
||||
|
||||
# gzip 压缩(保留原有配置)
|
||||
gzip on;
|
||||
gzip_min_length 1k;
|
||||
gzip_comp_level 9;
|
||||
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
|
||||
gzip_vary on;
|
||||
gzip_disable "MSIE [1-6]\.";
|
||||
|
||||
# 前端静态文件根目录(适配 Docker 挂载)
|
||||
root /usr/share/nginx/html;
|
||||
include /etc/nginx/mime.types;
|
||||
|
||||
# 静态资源缓存优化
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, max-age=604800";
|
||||
access_log off;
|
||||
}
|
||||
|
||||
# SPA 路由兜底
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# 错误页适配 SPA
|
||||
error_page 404 500 502 503 504 /index.html;
|
||||
|
||||
# 后端 API 代理(替换为实际地址)
|
||||
location /api {
|
||||
rewrite ^/api(.*)$ $1 break;
|
||||
proxy_pass http://150.158.236.152:5221; # 你的 Flask 后端地址
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user