165 lines
4.8 KiB
Plaintext
165 lines
4.8 KiB
Plaintext
# ============================================
|
|
# CaStAD Nginx Configuration
|
|
# ============================================
|
|
# 도메인:
|
|
# - castad.ktenterprise.net
|
|
# - ado2.whitedonkey.kr
|
|
# ============================================
|
|
|
|
# Upstream 설정
|
|
upstream castad_backend {
|
|
server 127.0.0.1:3001;
|
|
keepalive 64;
|
|
}
|
|
|
|
upstream castad_instagram {
|
|
server 127.0.0.1:5001;
|
|
keepalive 32;
|
|
}
|
|
|
|
# HTTP → HTTPS 리다이렉트
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name castad.ktenterprise.net ado2.whitedonkey.kr;
|
|
|
|
location /.well-known/acme-challenge/ {
|
|
root /var/www/certbot;
|
|
}
|
|
|
|
location / {
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
}
|
|
|
|
# HTTPS 서버 설정
|
|
server {
|
|
listen 443 ssl http2;
|
|
listen [::]:443 ssl http2;
|
|
server_name castad.ktenterprise.net ado2.whitedonkey.kr;
|
|
|
|
# SSL 인증서 (Let's Encrypt)
|
|
ssl_certificate /etc/letsencrypt/live/castad.ktenterprise.net/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/castad.ktenterprise.net/privkey.pem;
|
|
|
|
# SSL 설정
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_prefer_server_ciphers on;
|
|
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
|
|
ssl_session_cache shared:SSL:10m;
|
|
ssl_session_timeout 10m;
|
|
ssl_session_tickets off;
|
|
|
|
# HSTS
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
|
|
# 기타 보안 헤더
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header X-XSS-Protection "1; mode=block" always;
|
|
|
|
# 로그
|
|
access_log /var/log/nginx/castad_access.log;
|
|
error_log /var/log/nginx/castad_error.log;
|
|
|
|
# 파일 업로드 크기 제한 (영상 업로드용)
|
|
client_max_body_size 500M;
|
|
client_body_timeout 300s;
|
|
|
|
# 정적 파일 캐싱 (프론트엔드 빌드 파일)
|
|
root /var/www/castad/dist;
|
|
index index.html;
|
|
|
|
# Gzip 압축
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_min_length 1024;
|
|
gzip_proxied any;
|
|
gzip_types text/plain text/css text/xml text/javascript application/javascript application/json application/xml;
|
|
gzip_comp_level 6;
|
|
|
|
# 정적 자원 캐싱
|
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
try_files $uri =404;
|
|
}
|
|
|
|
# API 요청 → Backend
|
|
location /api/ {
|
|
proxy_pass http://castad_backend;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection 'upgrade';
|
|
proxy_set_header Host $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_cache_bypass $http_upgrade;
|
|
proxy_read_timeout 300s;
|
|
proxy_connect_timeout 75s;
|
|
}
|
|
|
|
# 렌더링 요청 → Backend (긴 타임아웃)
|
|
location /render {
|
|
proxy_pass http://castad_backend;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $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_read_timeout 600s;
|
|
proxy_connect_timeout 75s;
|
|
proxy_buffering off;
|
|
}
|
|
|
|
# 다운로드 파일
|
|
location /downloads/ {
|
|
proxy_pass http://castad_backend;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $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;
|
|
}
|
|
|
|
# 임시 파일
|
|
location /temp/ {
|
|
proxy_pass http://castad_backend;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $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;
|
|
}
|
|
|
|
# 업로드된 에셋
|
|
location /uploads/ {
|
|
proxy_pass http://castad_backend;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $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;
|
|
}
|
|
|
|
# Instagram 서비스 (내부 프록시)
|
|
location /instagram-service/ {
|
|
internal;
|
|
proxy_pass http://castad_instagram/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
}
|
|
|
|
# SPA 라우팅 - 모든 요청을 index.html로
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# 에러 페이지
|
|
error_page 500 502 503 504 /50x.html;
|
|
location = /50x.html {
|
|
root /usr/share/nginx/html;
|
|
}
|
|
}
|