# Rate limiting: 10 requests per second per IP (burst 20) limit_req_zone $binary_remote_addr zone=web:10m rate=10r/s; server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # Apply rate limiting to all requests limit_req zone=web burst=20 nodelay; limit_req_status 429; # 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 256; location / { try_files $uri $uri/ /index.html; } # Cache static assets location /assets/ { expires 1y; add_header Cache-Control "public, immutable"; } error_page 429 /429.html; location = /429.html { internal; default_type text/html; return 429 '429 Too Many Requests

429

请求过于频繁,请稍后再试

Rate limit: 10 requests/second per IP

'; } }