# 云小调前端 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;
|
}
|
}
|