vending-machine/admin/nginx.conf

39 lines
1.1 KiB
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 _;
root /usr/share/nginx/html;
index index.html;
# gzip 压缩
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
gzip_min_length 1024;
# 静态资源缓存Vite 构建产物带 hash可长期缓存
location /assets/ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# API 请求代理到后端服务
location /api/ {
proxy_pass http://vending-machine-api: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;
}
# 上传文件代理到后端服务
location /uploads/ {
proxy_pass http://vending-machine-api:8080;
proxy_set_header Host $host;
}
# Vue Router history 模式 — 所有路由回退到 index.html
location / {
try_files $uri $uri/ /index.html;
}
}