Files
reader-star/apps/admin/nginx.conf

35 lines
976 B
Nginx Configuration File
Raw Normal View History

server {
listen 80;
server_name localhost;
# 设置根目录为打包后的 dist 文件夹
root /usr/share/nginx/html;
index index.html;
# 开启 gzip 压缩
gzip on;
gzip_min_length 1k;
gzip_comp_level 6;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
# 核心配置:处理 SPA 路由 fallback
location / {
try_files $uri $uri/ /index.html;
}
# 静态资源缓存配置(可选)
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 30d;
add_header Cache-Control "public, no-transform";
}
# 代理接口配置(如果需要)
# location /api/ {
# proxy_pass http://backend-api.com/;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# }
}