@@ -6,23 +6,41 @@ upstream chat {
66 server backend-chat:8001;
77}
88
9+ # 1. HTTP 접속을 HTTPS로 자동 리다이렉트
910server {
1011 listen 80;
12+ server_name uniquestpiro.xyz www.uniquestpiro.xyz;
13+ return 301 https://$host$request_uri;
14+ }
15+
16+ # 2. 실제 HTTPS 통신 설정
17+ server {
18+ listen 443 ssl;
19+ server_name uniquestpiro.xyz www.uniquestpiro.xyz;
1120
12- # 1. Django 일반 페이지 및 API 처리
21+ # 발급받은 인증서 경로 (docker-compose에서 연결해줄 경로입니다)
22+ ssl_certificate /etc/letsencrypt/live/uniquestpiro.xyz/fullchain.pem;
23+ ssl_certificate_key /etc/letsencrypt/live/uniquestpiro.xyz/privkey.pem;
24+
25+ # SSL 보안 최적화 설정 (선택사항이지만 권장)
26+ ssl_protocols TLSv1.2 TLSv1.3;
27+ ssl_prefer_server_ciphers on;
28+
29+ # Django 일반 페이지 및 API 처리
1330 location / {
1431 proxy_pass http://core;
1532 proxy_set_header Host $host;
1633 proxy_set_header X-Real-IP $remote_addr;
1734 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
35+ proxy_set_header X-Forwarded-Proto $scheme;
1836 }
1937
20- # 2. 미디어 파일 처리 (이미지 업로드/조회 필수!)
38+ # 미디어 파일 처리
2139 location /media/ {
22- alias /app/media/; # docker-compose에서 연결한 경로
40+ alias /app/media/;
2341 }
2442
25- # 3. 채팅 서버 (WebSocket)
43+ # 채팅 서버 (WebSocket) - HTTPS 환경에서는 wss:// 로 접속하게 됩니다
2644 location /ws/ {
2745 proxy_pass http://chat;
2846 proxy_http_version 1.1;
@@ -31,30 +49,30 @@ server {
3149 proxy_set_header Host $host;
3250 proxy_set_header X-Real-IP $remote_addr;
3351 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
52+ proxy_set_header X-Forwarded-Proto $scheme;
3453 proxy_read_timeout 86400;
3554 }
3655
37- # ✨ 4. SSE 스트림 (미션 실시간 업데이트)
56+ # SSE 스트림 (미션 실시간 업데이트)
3857 location /stream/ {
3958 proxy_pass http://chat;
4059 proxy_http_version 1.1;
41- proxy_set_header Connection ''; # SSE는 keep-alive 필요
60+ proxy_set_header Connection '';
4261 proxy_set_header Host $host;
4362 proxy_set_header X-Real-IP $remote_addr;
4463 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
64+ proxy_set_header X-Forwarded-Proto $scheme;
4565
46- # SSE 핵심 설정
47- proxy_buffering off; # nginx 버퍼링 비활성화 (즉시 전송)
48- proxy_cache off; # 캐시 비활성화
49- proxy_read_timeout 86400; # 24시간 타임아웃
50- chunked_transfer_encoding off; # 청크 전송 비활성화
66+ proxy_buffering off;
67+ proxy_cache off;
68+ proxy_read_timeout 86400;
69+ chunked_transfer_encoding off;
5170
52- # CORS 설정 (필요시)
5371 add_header Cache-Control 'no-cache';
5472 add_header X-Accel-Buffering 'no';
5573 }
5674
57- # 5. 정적 파일 처리 (CSS/JS)
75+ # 정적 파일 처리
5876 location /static/ {
5977 alias /app/staticfiles/;
6078 }
0 commit comments