# 全局配置 worker_processes auto; events { worker_connections 1024; } http { # 开启 Gzip 压缩,减少传输数据量 gzip on; gzip_min_length 512; gzip_comp_level 5; gzip_types text/plain application/javascript application/x-javascript text/javascript text/css text/xml; gzip_disable "MSIE [1-6]\."; gzip_vary on; include mime.types; default_type application/octet-stream; # 服务器配置 server { listen 80; # 前端静态资源访问 location / { root html; index index.html index.htm; try_files $uri $uri/ /index.html; add_header Cache-Control no-cache; } # API 请求代理转发 location ^~ /api/ { rewrite ^/api/(.*)$ /$1 break; proxy_pass http://127.0.0.1:8090/; 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 600s; } # 错误页面处理 error_page 500 502 503 504 /50x.html; location = /50x.html { root /path/to/error-pages; } } }