33 lines
926 B
Nginx Configuration File
33 lines
926 B
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name _;
|
|
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# 字符集 + gzip
|
|
charset utf-8;
|
|
gzip on;
|
|
gzip_types text/css application/javascript text/javascript application/json
|
|
image/svg+xml application/xml text/xml application/xml+rss;
|
|
|
|
# 安全 headers
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
|
|
|
# SPA 回退(虽然当前没路由,但留个兜底)
|
|
location / {
|
|
try_files $uri $uri/ $uri.html /index.html;
|
|
}
|
|
|
|
# 静态资源缓存(图片 / css / js)
|
|
location ~* \.(css|js|jpg|jpeg|png|gif|svg|woff|woff2|ttf|eot)$ {
|
|
expires 30d;
|
|
add_header Cache-Control "public, max-age=2592000";
|
|
}
|
|
|
|
# 错误页 fallback
|
|
error_page 404 /index.html;
|
|
}
|