Files
huihuiSquare/digital-avatar-app/nginx.conf
T

47 lines
1.6 KiB
Nginx Configuration File

# 完整主配置:覆盖 nginx:alpine 默认 /etc/nginx/nginx.conf
# 新版 nginx 在受限容器内写 /run/nginx.pid 会报 Operation not permitted 并致命退出,
# 这里把 pid 显式改到可写的 /tmp(main 上下文唯一一处),避免前端容器反复重启。
pid /tmp/nginx.pid;
worker_processes auto;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# Docker 容器重建后 IP 可能变化;按内置 DNS 周期解析服务名,避免 Nginx 缓存旧地址导致 /api 502。
resolver 127.0.0.11 valid=10s ipv6=off;
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Keep the application gateway aligned with the production edge gateway.
# Without this Nginx rejects ordinary PDF uploads with HTTP 413 before
# FastAPI can return its user-facing file-size validation message.
client_max_body_size 20m;
# SPA 兜底(hash 路由下深链接也可正常加载)
location / {
try_files $uri $uri/ /index.html;
}
# 后端 API:保留 /api 前缀转发到 avatar-backend:8000
location /api/ {
set $avatar_backend http://avatar-backend:8000;
proxy_pass $avatar_backend;
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;
}
}
}