-
ubuntu 22.04 + nginx + certbot 사용으로 https 설정하기OS/Ubuntu 2023. 11. 24. 03:52
참고
- https://retromakers.tistory.com/27
- https://stackoverflow.com/questions/53223914/issue-using-certbot-with-nginx
Certbot, Let's Encrypt로 SSL 인증서 발급받기(Ubuntu, NGINX)
Let's Encrypt로 SSL 인증서를 발급받아 Https를 사용하는 방법을 알아보겠습니다. 우분투에 NGINX를 이용하여 홈페이지가 설정되어있다고 가정하겠습니다. 우선 certbot이 설치되어있느지 확인해 보면,
retromakers.tistory.com
Issue using certbot with nginx
I'm actually working on a webapp, I use Reactjs for the frontend and Golang for the backend. Those 2 programs are hosted separately on 2 VMs on Google-Compute-Engine. I want to serve my app through...
stackoverflow.com
1. certbot 설치
certbot은 snap 패키지를 사용해서 설치할 것을 권장한다.
https://certbot.eff.org/instructions?ws=other&os=snap하지만 snap 패키지는 certbot 설치 시에만 사용할 텐데,
snap 패키지를 이용하기 위한 부수적인 것들을 설치하기 싫어서 apt 명령어를 사용하기로 했다.apt install python3-certbot-nginx
2. domain 등록
certbot --nginx -d zhyun.kim -d www.zhyun.kim -d proj.zhyun.kim
짠!
3. 인증서 자동 갱신 설정
리눅스 작업 스케줄러인 crontab을 이용해서 매월 1일 새벽 1시에 인증서 갱신을 시도한다.
crontab은
분 시 일 월 요일 COMMAND
순서로 작성한다.crontab 실행
crontab -e
스케줄 등록
0 1 1 * * certbot renew --renew-hook="sudo systemctl restart nginx"
저장하고 빠져나오면 등록 성공이다.
만약 저장하고 빠져나왔는데, 아래와 같은 문장을 만난다면 cron 구문 오류이다.
나의 경우에 spring cron 구문이 "초/분/시/일/월/요일"인 것을 생각하고 똑같이 대입해 보다가 구문 오류가 났다 😓
리눅스는 "분/시/일/월/요일"이다 !
'OS > Ubuntu' 카테고리의 다른 글
Ubuntu Server / jdk + Tomcat 설치 (0) 2023.11.27 crontab 로그 남기기 (0) 2023.11.24 ubuntu 22.04에 nginx 설치하기 (0) 2023.11.24 ubuntu 22.04 - timezone 설정 (0) 2023.11.24 ubuntu 22.04에 oh-my-bash 적용하기 (1) 2023.11.23