44 lines
1.0 KiB
Plaintext
44 lines
1.0 KiB
Plaintext
server {
|
|
listen 80;
|
|
server_name localhost;
|
|
root /app/dist;
|
|
index index.html index.htm;
|
|
|
|
# 访问日志
|
|
access_log /app/logs/access.log main;
|
|
error_log /app/logs/error.log warn;
|
|
|
|
# 静态文件缓存
|
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
add_header Access-Control-Allow-Origin "*";
|
|
try_files $uri $uri/ =404;
|
|
}
|
|
|
|
# HTML文件不缓存
|
|
location ~* \.(html|htm)$ {
|
|
expires -1;
|
|
add_header Cache-Control "no-store, no-cache, must-revalidate";
|
|
try_files $uri $uri/ =404;
|
|
}
|
|
|
|
# SPA应用路由处理
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# 健康检查端点
|
|
location /health {
|
|
access_log off;
|
|
return 200 "healthy\n";
|
|
add_header Content-Type text/plain;
|
|
}
|
|
|
|
# 禁止访问隐藏文件
|
|
location ~ /\. {
|
|
deny all;
|
|
access_log off;
|
|
log_not_found off;
|
|
}
|
|
} |