add
This commit is contained in:
37
frontend/asset-assistant-system/nginx.conf
Normal file
37
frontend/asset-assistant-system/nginx.conf
Normal file
@@ -0,0 +1,37 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user