
POST요청이 Body를 통해 이뤄지기 때문에 GET요청 보단 안전하다고 하지만 이는 반은 맞고 반은 틀린 내용임.Let's Encrypt를 이용.sudo apt install certbot
sudo apt install python3-certbot-nginx
certbot: Let’s Encrypt에서 SSL 인증서를 발급,갱신,관리해 주는 프로그램.python3-certbot-nginx: certbot이 Nginx를 제어할 수 있도록 하는 Nginx 전용 플러그인.sudo certbot certonly --nginx
--nginx: Nginx 플러그인(python3-certbot-nginx)을 사용해 도메인 소유권 검증.Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
(Enter 'c' to cancel):
디버그 로그(실행 과정의 상세 기록)를 해당 경로에 저장.
인증서 갱신 안내 및 보안 공지용으로 사용할 이메일 입력.
90일마다 갱신해야함.그후 약관 동의? 같은 걸 묻고 아래와 같은 메시지가 나옴.
Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: α.site
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1
Requesting a certificate for α.site
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/α.site/fullchain.pem
Key is saved at: /etc/letsencrypt/live/α.site/privkey.pem
This certificate expires on 2026-03-14.
Let’s Encrypt(ACME 서버)에 α.site 도메인용 SSL 인증서 발급 요청을 전송했고
도메인 소유권 검증이 성공해서 Let’s Encrypt가 인증서를 발급해줬음.
2개의 pem파일이 /etc/letsencrypt/live/α.site/경로에 생성되었음.
fullchain.pem: 공개키 + 인증서(기관(Let's Encrypt)의 서명).privkey.pem: 비밀키.마지막 줄은 해당 인증서의 유효기간.
이렇게 인증서를 받는데 성공했고 이전 명령어에서 certonly 옵션을 사용했기 때문에 Certbot이 파일을 받아오기만 했을 뿐 Nginx 설정에는 아직 적용이 안 된 상태임.
server {
listen 80;
server_name α.site;
location / {
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
}
↓ 수정된 설정 (/etc/nginx/sites-available/파일명)
server {
listen 80;
server_name α.site;
rewrite ^ https://$server_name$request_uri? permanent;
}
server {
listen 443 ssl;
server_name α.site;
ssl_certificate /etc/letsencrypt/live/α.site/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/α.site/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
location / {
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
}
첫 번째 server {} 블록.
두 번째 server {} 블록.
include /etc/letsencrypt/options-ssl-nginx.conf: Certbot이 자동으로 생성해준 권장 SSL 보안 설정 파일.이제 새로운 설정을 ctrl+o 를 눌러 저장, ctrl + x로 빠져나와서
sudo systemctl restart nginx


↑ HTTPS 443이 추가된 모습.