fix(infra): nginx 동적 DNS resolve + Docker 헬스체크 추가

컨테이너 재생성 시 502 Bad Gateway 방지:
- 모든 nginx proxy_pass를 set $upstream 변수 방식으로 전환 (9개 파일, 24개 location)
- resolver 127.0.0.11 valid=10s ipv6=off 통합 선언
- ai-api location의 개별 resolver 8.8.8.8 제거 (server-level로 통합)
- 10개 API 서비스에 healthcheck 추가 (Node: wget, Python: urllib)
- 모든 web/gateway depends_on을 condition: service_healthy로 강화

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-03-23 12:53:34 +09:00
parent 2afcc4448b
commit 3d314c1fb4
10 changed files with 139 additions and 36 deletions

View File

@@ -1,6 +1,7 @@
server {
listen 80;
server_name _;
resolver 127.0.0.11 valid=10s ipv6=off;
client_max_body_size 50M;
@@ -25,7 +26,8 @@ server {
# API 프록시 (System 1 API)
location /api/ {
proxy_pass http://system1-api:3005/api/;
set $upstream http://system1-api:3005;
proxy_pass $upstream$request_uri;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
@@ -35,14 +37,17 @@ server {
# 업로드 파일 프록시 (^~ 로 regex location보다 우선 매칭)
location ^~ /uploads/ {
proxy_pass http://system1-api:3005/uploads/;
set $upstream http://system1-api:3005;
proxy_pass $upstream$request_uri;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
# FastAPI Bridge 프록시
location /fastapi/ {
proxy_pass http://system1-fastapi:8000/;
set $upstream http://system1-fastapi:8000;
rewrite ^/fastapi/(.*)$ /$1 break;
proxy_pass $upstream;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
@@ -52,7 +57,9 @@ server {
# SSO Auth 프록시 (gateway에서 이관)
location /auth/ {
proxy_pass http://sso-auth:3000/api/auth/;
set $upstream http://sso-auth:3000;
rewrite ^/auth/(.*)$ /api/auth/$1 break;
proxy_pass $upstream;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -61,7 +68,6 @@ server {
# AI Service 프록시 (gateway에서 이관)
location /ai-api/ {
resolver 8.8.8.8 valid=300s ipv6=off;
set $ai_upstream https://ai.hyungi.net;
rewrite ^/ai-api/(.*) /api/ai/$1 break;
proxy_pass $ai_upstream;