DEV/other things

Certbot을 통해 무료 SSL 발급받기(임시 및 갱신)

석봉 2024. 8. 19. 18:01

certbot으로 ssl 발급

 - 도메인은 미리 준비하자

 - 가비아와 같은 서비스를 이용하면 저렴하게 이용 가능한 도메인이 존재함

// apt update
sudo apt update

// certbot 설치
sudo apt install certbot python3-certbot-nginx

// nginx에서 발급받아야 함.
// systemctl status nginx
sudo systemctl stop nginx

// 방화벽 확인
sudo ufw allow 80
sudo ufw allow 443

// 도메인은 미리 준비하자. (본인은 가비아 사용)
sudo certbot --standalone -d <도메인주소> certonly

// 다음과 같이 진행됨
// Saving debug log to /var/log/letsencrypt/letsencrypt.log
// Enter email address (used for urgent renewal and security notices)
//  (Enter 'c' to cancel): <이메일 입력>

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Please read the Terms of Service at
// https://letsencrypt.org/documents/LE-SA-v1.4-April-3-2024.pdf. You must agree in
// order to register with the ACME server. Do you agree?
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// (Y)es/(N)o: yes

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Would you be willing, once your first certificate is successfully issued, to
// share your email address with the Electronic Frontier Foundation, a founding
// partner of the Let's Encrypt project and the non-profit organization that
// develops Certbot? We'd like to send you email about our work encrypting the web,
// EFF news, campaigns, and ways to support digital freedom.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// (Y)es/(N)o: no
// Account registered.
// Requesting a certificate for <도메인주소>

// 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 2024-11-17.
// These files will be updated when the certificate renews.
// Certbot has set up a scheduled task to automatically renew this certificate in the background.

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// If you like Certbot, please consider supporting our work by:
//  * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
//  * Donating to EFF:                    https://eff.org/donate-le
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

// (*나중에) 모든 인증서 갱신 명령어
certbot renew

 

Nginx 설정

 - 에디터로 nginx 설정 파일 오픈 후 링크 참조하여 수정

sudo vi /etc/nginx/sites-available/default

https://seokbong.tistory.com/283

 

Nginx 다운로드 및 기본 설정방법 (+ EC2 with NodeJs)

// nginx 설치 (설치시 자동 실행)sudo apt updatesudo apt install nginx// nginx 상태확인sudo systemctl status nginx  EC2에서 apt install로 정상적으로 설치되었다면 설치한 EC2의 퍼블릭 IPv4 주소로 접속하면 위와 같

seokbong.tistory.com

 

 

+ 자동갱신 추가

// 한국시 적용
sudo ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime

// 에디터 접속
sudo vim /etc/crontab

// 에디터에 다음 내용 추가 (매달 1일 자동 갱신 후 nginx 재실행)
0 0 1 * * certbot renew --renew-hook="sudo systemctl restart nginx"

// 에디터 저장
:wq

// 적용
sudo service cron restart

 

+ 자동갱신 수정(?)