Skip to content

Commit

Permalink
Merge pull request #142 from boostcampwm-2024/Feature/#136_NginX_HTTPS
Browse files Browse the repository at this point in the history
Feature/#136 HTTPS 접속을 μœ„ν•œ NginX μ„€μ • λ³€κ²½
  • Loading branch information
github-actions[bot] authored Nov 18, 2024
2 parents 07c63f7 + 01f8886 commit 59a22c5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ services:
dockerfile: ./nginx/Dockerfile
ports:
- "80:80"
- "443:443"
volumes:
- ./client/dist:/usr/share/nginx/html
- /etc/letsencrypt:/etc/letsencrypt:ro
depends_on:
- frontend
- backend
Expand Down
1 change: 1 addition & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ WORKDIR /usr/share/nginx/html
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf

EXPOSE 80
EXPOSE 443
CMD ["nginx", "-g", "daemon off;"]
30 changes: 30 additions & 0 deletions nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,38 @@ upstream backend {
server backend:3000; # λ°±μ—”λ“œ μ„œλ²„ (NestJS)
}

# HTTP μ„œλ²„ 블둝
server {
listen 80;
server_name nocta.site www.nocta.site;

# Let's Encrypt 인증을 μœ„ν•œ μ„€μ •
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}

# HTTPS둜 λ¦¬λ‹€μ΄λ ‰νŠΈ
location / {
return 301 https://$host$request_uri;
}
}

# HTTPS μ„œλ²„ 블둝
server {
listen 443 ssl;
server_name nocta.site www.nocta.site;

# SSL μΈμ¦μ„œμ™€ ν‚€ 파일 경둜
ssl_certificate /etc/letsencrypt/live/nocta.site/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/nocta.site/privkey.pem;

# SSL μ„€μ •
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers HIGH:!aNULL:!MD5;

# HSTS μ„€μ • (HTTPS κ°•μ œ)
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

# /api 경둜둜 λ“€μ–΄μ˜€λŠ” μš”μ²­μ€ λ°±μ—”λ“œλ‘œ 전달
location /api {
Expand Down

0 comments on commit 59a22c5

Please sign in to comment.