SunnyFarm/frontend/nginx.conf
2026-02-28 07:15:26 +08:00

33 lines
828 B
Nginx Configuration File
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 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;
}
}