Files
asset_assistant/frontend/asset-assistant-system/nginx.conf
2025-11-12 17:10:40 +08:00

37 lines
1.0 KiB
Nginx Configuration File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html; # 入口文件指向项目根目录的 index.html
# 支持 SPA 路由重写关键解决刷新404
location / {
try_files $uri $uri/ /index.html;
add_header Cache-Control "no-cache"; # 入口文件不缓存
}
# 静态资源缓存配置JS/CSS/图片等)
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|otf)$ {
expires 7d; # 缓存7天
add_header Cache-Control "public, max-age=604800";
add_header Access-Control-Allow-Origin "*"; # 允许跨域(可选)
}
# 禁止访问隐藏文件(如 .git、.env 等)
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
# 优化 Nginx 响应速度
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# 关闭不必要的日志
access_log off;
error_log /var/log/nginx/error.log warn;
}