Nginx's Role
Nginx is used as a reverse proxy across all projects — hr_blog2.0, XGen, PolaRAG, and others.
Nginx Architecture
graph TD
A[클라이언트] -->|HTTPS| B[Nginx :443]
B -->|HTTP| C[Frontend :3000]
B -->|HTTP| D[Backend :8000]
B -->|HTTP| E[MinIO :9000]
B -->|SSL 종단| F[인증서 관리]
B -->|라우팅| G[URL 패턴 매칭]
B -->|캐싱| H[정적 파일 캐시]
Base Configuration
# nginx.conf
worker_processes auto;
events {
worker_connections 1024;
}
http {
# Base settings
sendfile on;
keepalive_timeout 65;
client_max_body_size 50M;
# Gzip compression
gzip on;
gzip_types text/plain application/json application/javascript text/css;
include /etc/nginx/conf.d/*.conf;
}
SSL Configuration
server {
listen 80;
server_name hrletsgo.me;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name hrletsgo.me;
ssl_certificate /etc/nginx/cert/fullchain.pem;
ssl_certificate_key /etc/nginx/cert/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
}
API Routing
# API requests → Backend
location /api/ {
proxy_pass http://backend:8000;
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;
}
# Static files → Frontend
location / {
proxy_pass http://frontend:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
WebSocket Support
Configured to support both SSE and WebSocket:
# SSE (Server-Sent Events)
location /api/stream/ {
proxy_pass http://backend:8000;
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 86400s;
}
Static File Caching
location /_next/static/ {
proxy_pass http://frontend:3000;
expires 365d;
add_header Cache-Control "public, immutable";
}
This configuration pattern is reusable across virtually any web project.