server { listen 80; server_name 192.168.1.88; root /www/wwwroot/ggl/dist; index index.html index.htm; # 静态资源缓存配置 location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { expires 1y; add_header Cache-Control "public, immutable"; access_log off; } # API请求代理到后端Node.js服务 location /api/ { proxy_pass http://127.0.0.1:4001; 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 30s; proxy_read_timeout 60s; proxy_send_timeout 30s; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } # uploads目录代理到后端 location /uploads/ { proxy_pass http://127.0.0.1:4001; 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; } # 前端路由处理 - 所有其他请求返回index.html location / { try_files $uri $uri/ /index.html; } # 禁止访问敏感文件 location ~ ^/(\.|package\.json|package-lock\.json|\.env) { return 404; } # SSL证书验证目录 location /.well-known/ { root /www/wwwroot/ggl; } # 日志配置 access_log /www/wwwlogs/高句丽.log; error_log /www/wwwlogs/高句丽.error.log; }