1+ events { }
2+
3+ http {
4+ upstream frontend {
5+ server dev-chat-frontend-${ACTIVE_COLOR}:80; # React 컨테이너
6+ }
7+
8+ upstream backend {
9+ server dev-chat-backend-${ACTIVE_COLOR}:8080; # Spring Boot 컨테이너
10+ }
11+
12+ server {
13+ listen 80;
14+ server_name thedevchat.duckdns.org;
15+
16+ # HTTP -> HTTPS 리다이렉트
17+ return 301 https://$host$request_uri;
18+ }
19+
20+ server {
21+ listen 443 ssl;
22+ server_name thedevchat.duckdns.org;
23+
24+ ssl_certificate /etc/letsencrypt/live/thedevchat.duckdns.org/fullchain.pem;
25+ ssl_certificate_key /etc/letsencrypt/live/thedevchat.duckdns.org/privkey.pem;
26+
27+ ssl_protocols TLSv1.2 TLSv1.3;
28+ ssl_ciphers HIGH:!aNULL:!MD5;
29+
30+ # React 프론트엔드 프록시
31+ location / {
32+ proxy_pass http://frontend;
33+ proxy_http_version 1.1;
34+
35+ proxy_set_header Host $host;
36+ proxy_set_header X-Real-IP $remote_addr;
37+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
38+ proxy_set_header X-Forwarded-Proto $scheme;
39+
40+ # SPA 라우팅을 위한 fallback 설정
41+ proxy_intercept_errors on;
42+ error_page 404 = /index.html;
43+ }
44+
45+ # API 요청은 백엔드로 프록시
46+ location /api/ {
47+ proxy_pass http://backend/;
48+ proxy_http_version 1.1;
49+
50+ proxy_set_header Host thedevchat.duckdns.org;
51+ proxy_set_header X-Real-IP $remote_addr;
52+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
53+ proxy_set_header X-Forwarded-Proto $scheme;
54+
55+ proxy_cache_bypass $http_upgrade;
56+ }
57+
58+ # WebSocket 프록시
59+ location /ws {
60+ proxy_pass http://backend;
61+ proxy_http_version 1.1;
62+
63+ proxy_set_header Upgrade $http_upgrade;
64+ proxy_set_header Connection "Upgrade";
65+
66+ proxy_set_header Host thedevchat.duckdns.org;
67+ proxy_set_header X-Real-IP $remote_addr;
68+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
69+ proxy_set_header X-Forwarded-Proto $scheme;
70+ proxy_cache_bypass $http_upgrade;
71+ }
72+
73+ # index.html 직접 서빙용 (에러 발생시 대응)
74+ location = /index.html {
75+ proxy_pass http://frontend/index.html;
76+ }
77+ }
78+ }
0 commit comments