server { listen 80; server_name localhost; # 基础设置 root /usr/share/nginx/html; index index.html index.htm; try_files $uri $uri/ /index.html; client_max_body_size 100m; # 错误页面配置 error_page 500 502 503 504 /50x.html; location = /50x.html { internal; # 仅用于内部错误请求 } # Gzip 压缩设置 gzip on; gzip_min_length 1k; gzip_comp_level 6; gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml; gzip_vary on; gzip_disable "MSIE [1-6]\."; # 静态资源缓存优化 location ~* \.(jpg|jpeg|gif|ico|css|js)$ { expires 7d; add_header Cache-Control "public, no-transform"; } }