53 lines
1.2 KiB
Nginx Configuration File
53 lines
1.2 KiB
Nginx Configuration File
# ==========================================
|
|
# Vue 项目 Nginx 配置模板
|
|
# 配合 Dockerfile.vue 使用
|
|
# ==========================================
|
|
|
|
server {
|
|
listen 80;
|
|
server_name localhost;
|
|
|
|
# 日志格式
|
|
access_log /var/log/nginx/access.log;
|
|
error_log /var/log/nginx/error.log;
|
|
|
|
# 站点根目录
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# 静态资源长期缓存
|
|
location /assets/ {
|
|
expires 30d;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
# Vue Router history 模式支持
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# API 代理(如果有后端代理需求,可在此配置)
|
|
# location /api/ {
|
|
# proxy_pass http://backend-server:8080/;
|
|
# proxy_set_header Host $host;
|
|
# proxy_set_header X-Real-IP $remote_addr;
|
|
# }
|
|
|
|
# Gzip 压缩
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_comp_level 6;
|
|
gzip_types
|
|
text/plain
|
|
text/css
|
|
text/xml
|
|
text/javascript
|
|
application/json
|
|
application/javascript
|
|
application/xml+rss
|
|
application/x-javascript
|
|
image/svg+xml;
|
|
gzip_min_length 1024;
|
|
gzip_proxied any;
|
|
}
|