server { listen 10084; server_name localhost; # 如果有域名,替换为您的域名 # 网站根目录,请根据实际情况修改路径 root /var/www/threejs-digital-steelmill/dist; index index.html; # 字符集 charset utf-8; # 访问日志 access_log /var/log/nginx/steelmill_access.log; error_log /var/log/nginx/steelmill_error.log; # gzip 压缩配置 gzip on; gzip_vary on; gzip_min_length 1024; gzip_comp_level 6; gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/xml+rss application/rss+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xml; # 静态资源缓存配置 location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$ { expires 1y; add_header Cache-Control "public, immutable"; access_log off; } # 3D 模型文件缓存 location ~* \.(glb|gltf|bin|hdr)$ { expires 1y; add_header Cache-Control "public, immutable"; access_log off; } # WebAssembly 文件配置 location ~* \.wasm$ { types { application/wasm wasm; } expires 1y; add_header Cache-Control "public, immutable"; } # SPA 路由支持 - 所有路由都返回 index.html location / { try_files $uri $uri/ /index.html; add_header Cache-Control "no-cache"; } # 安全头部配置 add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Content-Type-Options "nosniff" always; add_header X-XSS-Protection "1; mode=block" always; # 禁止访问隐藏文件 location ~ /\. { deny all; access_log off; log_not_found off; } }