tools/nginx.conf.example

41 lines
1.0 KiB
Plaintext
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 your-domain.com;
root /path/to/your/website/dist; # 指向构建后的dist目录
index index.html;
# 优化静态资源缓存
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 30d;
add_header Cache-Control "public, no-transform";
}
# HTML文件不缓存确保始终获取最新版本
location ~* \.html$ {
expires -1;
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate";
}
# 启用gzip压缩
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_comp_level 6;
gzip_min_length 1000;
# 默认处理
location / {
try_files $uri $uri/ /index.html;
}
# 禁止直接访问敏感文件
location ~ /\.(git|gitignore) {
deny all;
}
# 错误页面处理
error_page 404 /404.html;
location = /404.html {
root /path/to/your/website/dist;
internal;
}
}