본문 바로가기

Cloud/Oracle Cloud

[Oracle Cloud] 10. 무료 SSL 인증서 적용

도메인까지 구매해 연결을 완료했으니 SSL 인증서를 적용한다.

 

Let's Encrypt를 이용해 진행한다.

 

http와 https의 차이점은 추후에 자세히 포스팅하기로하고 일단은 적용부터

 

1. Certbot 설치

yum install epel-release
yum install certbot
yum install python3-certbot-nginx

 

 

설치 확인

certbot --version

 

 

2. nginx.conf 설정

vi /etc/nginx/nginx.conf

server.server_name 에 도메인 입력

 

# nginx.conf test
nginx -t

# reload
systemctl restart nginx.service

 

이전 방화벽 오픈 때 https 기본 포트인 443도 오픈 해두었기 때문에  바로 인증서를 발급받으면 된다.

 

certbot --nginx -d ${ url } # -d ${ url2 } 형태로 한 번에 여러 도메인에 대한 인증서 발급

 

이 명령어를 통해 certbot이 nginx설정을 자동으로 설정해준다.

다시 nginx service 재기동

# reload
systemctl restart nginx.service

 

자물쇠가 달린 것을 확인할 수 있다~

다만 Let's Encrypt는 90일마다 인증서를 갱신해주어야 하는데, crontab에 내용을 추가해서 자동으로 진행하게 한다.

certbot renew --dry-run

이 명령어로 갱신이 되는지 여부부터 확인한다.

 

매월 1일에 갱신하고 nginx를 다시 실행할 수 있도록 crontab 설정

 

# crontab 생성, 수정
crontab -e

0 0 1 * * certbot renew --renew-hook "sudo systemctl restart nginx"

 

다음달에 모니터링 한다~