33 lines
828 B
Nginx Configuration File
33 lines
828 B
Nginx Configuration File
server {
|
||
listen 80;
|
||
server_name localhost;
|
||
root /usr/share/nginx/html;
|
||
index index.html;
|
||
|
||
# Gzip压缩
|
||
gzip on;
|
||
gzip_min_length 1k;
|
||
gzip_comp_level 6;
|
||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
||
gzip_vary on;
|
||
|
||
# Vue Router History模式 - SPA路由支持
|
||
location / {
|
||
try_files $uri $uri/ /index.html;
|
||
}
|
||
|
||
# 静态资源长期缓存(Vite构建带hash)
|
||
location /assets/ {
|
||
expires 30d;
|
||
add_header Cache-Control "public, immutable";
|
||
access_log off;
|
||
}
|
||
|
||
# 图片等资源缓存
|
||
location ~* \.(ico|png|jpg|jpeg|gif|svg|webp)$ {
|
||
expires 7d;
|
||
add_header Cache-Control "public";
|
||
access_log off;
|
||
}
|
||
}
|