오라클 클라우드
Let's Encrypt 무료 SSL 인증서 설치하기
ethanjoh
2025. 4. 14. 11:13
먼저 해야할 일은 오라클 프리티어에서 HTTPS에 대한 포트 443을 열어두어야 한다.
그 다음 아래와 같은 명령을 실행한다.
$ sudo apt update
$ sudo apt install certbot python3-certbot-nginx -y
$ sudo certbot --nginx -d 도메인명 -d 도메인명
설치 시 이메일 주소와 서비스계약에 동의하는지 묻는데 y, 그 다음에 이메일을 단체와 공유할 것인지 묻는데 n 를 선택해도 된다.
설치에 성공하면 아래와 같은 메시지를 볼 수 있다. (여기서 도메인명은 자신의 도메인이 보일 것이다.)
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/도메인명/fullchain.pem
Key is saved at: /etc/letsencrypt/live/도메인명/privkey.pem
This certificate expires on 2025-07-13.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.
Deploying certificate
Successfully deployed certificate for wisdom.me.kr to /etc/nginx/sites-enabled/default
Congratulations! You have successfully enabled HTTPS on https://도메인명
그런데 인증서 만료일이 2025-07-13으로 나온다.
90일 뒤면 만료가 되기 때문에 자동갱신을 설정하는 것이 편하다.
$ sudo crontab -e
no crontab for root - using an empty one
Select an editor. To change later, run 'select-editor'.
1. /bin/nano <---- easiest
2. /usr/bin/vim.basic
3. /usr/bin/vim.tiny
4. /bin/ed
사용하기 쉬운 1번 nano 에디터를 선택하고 아래의 내용을 추가한다.
0 3,17 1 * * /usr/bin/certbot renew –renew-hook=”sudo systemctl restart nginx”
필드값의미
Minute | 0 | 매 시간의 0분에 실행 |
Hour | 3,17 | 오전 3시와 오후 5시에 실행 |
Day of Month | 1 | 매월 1일에 실행 |
Month | * | 모든 달에 실행 |
Day of Week | * | 요일에 관계없이 실행 |
매월 1일 오전 3시와 오후 5시에 certbot을 실행하여 SSL 인증서를 갱신하고 nginx 웹서버를 재시작하라는 뜻이다.
이것이 제대로 작동하는지 테스트하려면 아래와 같은 명령을 준다. (시뮬레이션이므로 시스템에 영향을 미치지 않는다.)
$ sudo certbot renew --dry-run
(생략)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all simulated renewals succeeded:
/etc/letsencrypt/live/도메인명/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
인증서 만료일을 확인하려면 아래 명령어를 실행한다.
$ sudo certbot certificates
최종적으로 https://로 접속하는 것을 확인했다.