项目文件夹

文件
2026-07-13 12:28:11 +08:00

42 行
1.5 KiB
Plaintext

此文件含有模棱两可的 Unicode 字符
此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。
# 单镜像(Dockerfile.complete / 一体化部署)专用 nginx 配置。
#
# 与 nginx/default.confdocker-compose 多容器版)的关键区别:
# - 前端不再由独立的 frontend 容器提供,构建产物已直接 COPY 到本镜像的
# /usr/share/nginx/html,所以 location / 走【静态文件】而非反代 frontend;
# - backend 与 nginx 同处一个容器,所以 /api、/static 代理到 127.0.0.1:8483。
#
# 注意:请勿把本文件的 location / 改成代理 frontend,否则单镜像里没有 frontend
# 服务,会回退到 nginx 默认欢迎页。多容器(compose)请改 nginx/default.conf。
server {
listen 80;
client_max_body_size 10G;
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_proxied any;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
# 前端静态文件由本容器直接服务(构建产物已 COPY 到此目录)
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
# backend 与 nginx 同容器,代理到本地
location /api/ {
proxy_pass http://127.0.0.1:8483;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /static/ {
proxy_pass http://127.0.0.1:8483/static/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
expires 7d;
add_header Cache-Control "public, immutable";
}
}