# chatbotApp 단독 웹서버 — Next.js 정적 UI + 챗 API 프록시 # 기본 upstream: https://chatbot.exdev.co.kr (Caddy → kakaoChatbotSkill /web/ask) # 로컬 kakao-skill(:8083) 사용 시: # CHATBOT_API_UPSTREAM=http://host.docker.internal:8083/web/ # CHATBOT_API_HOST=host.docker.internal # 레거시 RAG 직접(:28012) 사용 시: # CHATBOT_API_UPSTREAM=http://host.docker.internal:28012/chatbot/ # # Next.js 빌드(basePath=/chatbot/app)의 CSS·JS는 /chatbot/app/_next/ 경로를 사용합니다. # /chatbot/ API 프록시보다 정적 location을 먼저 두어야 스타일이 적용됩니다. map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; client_max_body_size 1m; # Next.js 정적 자산 + SPA (운영과 동일 경로 /chatbot/app/, /chatbot/ai/) location = /chatbot/app { return 301 /chatbot/app/; } location ^~ /chatbot/app/ { alias /usr/share/nginx/html/; index index.html; add_header Cache-Control "no-cache, no-store, must-revalidate"; } location = /chatbot/ai { return 301 /chatbot/ai/; } location ^~ /chatbot/ai/ { alias /usr/share/nginx/html-ai/; index index.html; add_header Cache-Control "no-cache, no-store, must-revalidate"; } location = /chatbot/banner { return 301 /chatbot/banner/; } location ^~ /chatbot/banner/ { alias /usr/share/nginx/html-banner/; index index.html; add_header Cache-Control "no-cache, no-store, must-revalidate"; add_header Content-Security-Policy "frame-ancestors *" always; } location = /chatbot/sample { return 301 /chatbot/sample/; } location ^~ /chatbot/sample/ { alias /usr/share/nginx/html-sample/; index index.html; add_header Cache-Control "no-cache, no-store, must-revalidate"; add_header Permissions-Policy "microphone=*, camera=()" always; } location = /chatbot/voicebot { return 301 /chatbot/voicebot/; } location ^~ /chatbot/voicebot/ { alias /usr/share/nginx/html-voicebot/; index index.html; add_header Cache-Control "no-cache, no-store, must-revalidate"; add_header Content-Security-Policy "frame-ancestors *" always; add_header Permissions-Policy "microphone=*, camera=()" always; } # 루트 접속 → basePath와 동일 URL로 이동 location = / { return 302 /chatbot/app/; } # RAG API (ask/stream/faq/session/health 등) — 원격 exAiChatBot 또는 로컬 RAG location /chatbot/ { proxy_pass ${CHATBOT_API_UPSTREAM}; proxy_http_version 1.1; proxy_ssl_server_name on; proxy_set_header Host ${CHATBOT_API_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; proxy_connect_timeout 10s; proxy_read_timeout 120s; proxy_send_timeout 120s; proxy_buffering off; } location / { try_files $uri $uri/ /index.html; add_header Cache-Control "no-cache, no-store, must-revalidate"; } }