events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; # 静态文件服务器 server { listen 80; server_name localhost; # 根目录指向 docs 文件夹 root /usr/share/nginx/html/docs; index test-chat.html index.html index.htm; # 主要测试页面 location / { try_files $uri $uri/ /test-chat.html; } # 直接访问 test-chat.html location /test-chat.html { add_header Cache-Control "no-cache, no-store, must-revalidate"; add_header Pragma "no-cache"; add_header Expires "0"; } # 其他静态文件 location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|html)$ { expires 7d; add_header Cache-Control "public, immutable"; } # 禁止访问隐藏文件 location ~ /\. { deny all; access_log off; log_not_found off; } # 自定义错误页面 error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } } }