chengmw
2026-04-02 6b14010e1765842acc437ab130e5815bc623788d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# 云小调前端 Nginx 配置
# 服务器:36.140.67.217
# 后端API:http://36.140.67.217:9015
 
server {
    listen 9002;
    server_name 36.140.67.217;
 
    # 前端静态资源
    root /var/www/cloud-melody-front;
    index index.html;
 
    # 开启 gzip 压缩
    gzip on;
    gzip_vary on;
    gzip_min_length 1024;
    gzip_proxied any;
    gzip_types text/plain text/css text/xml text/javascript application/javascript application/json application/xml;
    gzip_comp_level 6;
 
    # 静态资源缓存
    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
        expires 30d;
        add_header Cache-Control "public, immutable";
    }
 
    # API 代理转发到后端 Python 服务
    # 前端请求 /api/v1/xxx -> 后端 http://127.0.0.1:9015/api/v1/xxx
    location /api/ {
        proxy_pass http://127.0.0.1:9015;
        proxy_http_version 1.1;
        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_connect_timeout 60s;
        proxy_send_timeout 60s;
        proxy_read_timeout 60s;
    }
 
    # React Router 支持 - 所有路由返回 index.html
    location / {
        try_files $uri $uri/ /index.html;
    }
 
    # 禁止访问隐藏文件
    location ~ /\. {
        deny all;
    }
}