Skip to content

Commit

Permalink
Merge pull request #300 from boostcampwm-2024/feat/https-setting
Browse files Browse the repository at this point in the history
📦 chore: Let's Encrypt SSL/TLS 인증서 발급 및 Nginx 설정 추가
  • Loading branch information
asn6878 authored Dec 26, 2024
2 parents 114d409 + 40e8aee commit 80e3b9b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
34 changes: 24 additions & 10 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -1,31 +1,45 @@
# HTTP로 들어오는 요청을 HTTPS로 Redirect
server {
listen 80 default_server;
server_name _;
listen 80;
server_name denamu.site www.denamu.site;

return 301 https://$host$request_uri;
}

# HTTPS로 들어온 요청에 대한 처리 진행
server {
listen 443 ssl;
server_name denamu.site www.denamu.site;

ssl_certificate /etc/letsencrypt/live/denamu.site/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/denamu.site/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

# 정적 파일 서빙 - FE 빌드 파일
location / {
root /var/web05-Denamu/client/dist;
index index.html; # 기본 파일 설정
try_files $uri /index.html; # SPA 지원
index index.html;
try_files $uri /index.html;
}

# 정적 파일 서빙
location /files {
alias /var/web05-Denamu/static/;
try_files $uri $uri/ =404; # 파일이 없으면 404 반환
}
location /files {
alias /var/web05-Denamu/static/;
try_files $uri $uri/ =404;
}

# API 요청을 NestJS로 프록시
location /api {
proxy_pass http://127.0.0.1:8080; # NestJS 서버
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

# WebSocket 요청 프록시
# WebSocket 요청 프록시
location /chat {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
Expand Down
2 changes: 1 addition & 1 deletion server/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function bootstrap() {
app.enableCors({
origin: [
'http://localhost:5173',
'https://denamu.netlify.app',
'https://www.denamu.site',
'https://denamu.site',
],
credentials: true,
Expand Down

0 comments on commit 80e3b9b

Please sign in to comment.