Files

78 lines
2.0 KiB
Nginx Configuration File
Raw Permalink Normal View History

# ============================================
2026-06-23 10:40:10 +08:00
# 云睿资产管理系统 - Nginx 配置
# 功能:serve 前端静态文件 + 反向代理 API
# ============================================
server {
listen 80;
server_name localhost;
# 前端静态文件
root /usr/share/nginx/html;
index index.html;
# Gzip 压缩
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript image/svg+xml;
gzip_min_length 1024;
gzip_vary on;
# 前端路由(SPA 支持)
location / {
try_files $uri $uri/ /index.html;
}
# API 反向代理到后端
location /api/ {
proxy_pass http://backend:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
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_cache_bypass $http_upgrade;
# 超时设置
proxy_read_timeout 120s;
proxy_send_timeout 120s;
}
# 上传文件访问
location /uploads/ {
proxy_pass http://backend:8000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
# 健康检查端点
location /health {
proxy_pass http://backend:8000;
proxy_http_version 1.1;
proxy_set_header Host $host;
}
# API 文档
location /api-docs {
proxy_pass http://backend:8000;
proxy_http_version 1.1;
proxy_set_header Host $host;
}
# 禁止访问隐藏文件
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
# 静态资源缓存策略
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?|ttf|eot)$ {
expires 30d;
add_header Cache-Control "public, immutable";
access_log off;
}
}