mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-06-17 21:50:15 +08:00
nginx/default.conf 被 docker-compose(多容器)与 Dockerfile.complete(单镜像) 共用,但两种模式对 location / 的需求相反:多容器需反代独立的 frontend 容器, 单镜像需直接服务本地静态文件。此前共用一份配置,导致其中一种部署总会回退到 nginx 默认欢迎页(本次为 compose 入口 nginx 用了 root 但容器内无前端产物)。 拆分为两份配置,各司其职、互不干扰: - nginx/default.conf:compose 版,location / 反代 http://frontend:80 - nginx/standalone.conf(新增):单镜像版,location / 服务 /usr/share/nginx/html, /api、/static 代理到本地 127.0.0.1:8483 - Dockerfile.complete 改用 standalone.conf,移除不再需要的 sed 改写 已用 nginx -t 校验 standalone.conf 语法通过。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
31 lines
865 B
Plaintext
31 lines
865 B
Plaintext
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;
|
|
|
|
# 多容器(docker-compose)部署:前端在独立的 frontend 容器,代理过去。
|
|
# 单镜像(Dockerfile.complete)部署请勿用本文件,改用 nginx/standalone.conf。
|
|
location / {
|
|
proxy_pass http://frontend:80;
|
|
}
|
|
|
|
location /api/ {
|
|
proxy_pass http://backend:8483;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
}
|
|
|
|
location /static/ {
|
|
proxy_pass http://backend:8483/static/;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
expires 7d;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
}
|