server {
    listen       80;
    server_name  localhost;

    charset utf-8;

    # 静态资源根目录
    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;
    gzip_disable     "MSIE [1-6]\.";

    # 静态资源缓存（Vite 构建产物带 hash，可长期缓存）
    location /assets/ {
        expires 1y;
        add_header Cache-Control "public, immutable";
    }

    # 后端 API 代理（接入后端时取消注释，把 backend 换成实际地址）
    # location /prod-api/ {
    #     proxy_pass http://backend:8080/;
    #     proxy_set_header Host              $host;
    #     proxy_set_header X-Real-IP         $remote_addr;
    #     proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
    #     proxy_set_header X-Forwarded-Proto $scheme;
    # }

    # Vue Router history 模式 — 所有未匹配路径回退到 index.html
    location / {
        try_files $uri $uri/ /index.html;
    }

    # 禁止访问隐藏文件
    location ~ /\. {
        deny all;
    }
}
