From ae3d3a205eb4c2f6c386995fbc9cf1e79a5ad926 Mon Sep 17 00:00:00 2001 From: zzuhannn Date: Thu, 30 Apr 2026 18:46:58 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20nginx=20HTTPS=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20(Let's=20Encrypt=20+=20HTTP=E2=86=92HTTPS?= =?UTF-8?q?=20=EB=A6=AC=EB=8B=A4=EC=9D=B4=EB=A0=89=ED=8A=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nginx/conf.d/default.conf | 59 ++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/nginx/conf.d/default.conf b/nginx/conf.d/default.conf index 5bf0ed7..e08c358 100644 --- a/nginx/conf.d/default.conf +++ b/nginx/conf.d/default.conf @@ -1,33 +1,36 @@ - server { - listen 80; - server_name 15.165.98.76.nip.io; +# HTTP -> HTTPS 리다이렉트 (단, ACME challenge는 그대로 통과) +server { + listen 80; + server_name 15.165.98.76.nip.io; - location /.well-known/acme-challenge/ { - root /var/www/certbot; - } + location /.well-known/acme-challenge/ { + root /var/www/certbot; + } - location = /healthz { - return 200 'kkumteul backend is running\n'; - add_header Content-Type text/plain; - } + location / { + return 301 https://$host$request_uri; + } +} - location / { - proxy_pass http://backend:8080; - 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; - } - } - } +# HTTPS 메인 서버 +server { + listen 443 ssl; + server_name 15.165.98.76.nip.io; - location = /healthz { - return 200 'kkumteul backend is running\n'; - add_header Content-Type text/plain; - } + ssl_certificate /etc/letsencrypt/live/15.165.98.76.nip.io/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/15.165.98.76.nip.io/privkey.pem; - location / { proxy_pass http://backend:8080; 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; - } } \ No newline at end of file + location = /healthz { + return 200 'kkumteul backend is running\n'; + add_header Content-Type text/plain; + } + + location / { + proxy_pass http://backend:8080; + 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; + } +}