Files
admin/www/nginx.conf
T
2026-08-11 16:45:25 +08:00

41 lines
1.3 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 _;
# Nuxt SPA 构建产物(nuxt build + ssr:false,静态文件位于 .output/public
root /usr/share/nginx/html;
index index.html;
client_max_body_size 50m;
gzip on;
gzip_types text/plain text/css application/json application/javascript image/svg+xml;
# 带内容指纹的构建资源:长缓存(正则含 {},必须加引号避免被当作块定界符)
location ~* "\.[0-9a-f]{8}\.(js|css|png|jpg|jpeg|gif|webp|svg|woff2?)$" {
expires 365d;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# SPA history 回退:i18n 英文前缀 /en 及各路由均由前端接管
location / {
try_files $uri $uri/ /index.html;
}
# CMS API 与素材静态文件:反代到 backend 容器(compose 网络内服务名解析)
location /api/ {
proxy_pass http://backend:8000;
proxy_http_version 1.1;
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://backend:8000;
proxy_set_header Host $host;
expires 7d;
}
}