SSL 인증서 갱신
Let’s Encrypt 무료 SSL 인증서는 3개월 단위로 인증서가 발급됩니다. 3개월 마다 수동으로 이를 업데이트 하려면 많은 신경을 써야하고 바쁘다 보면 그냥 지나칠 경우도 있습니다.
이번 부엉이 개발자 사이트를 개발하는데 이 인증서를 사용한 이유도 바로 Let’s Encrypt 가 인증서 자동 갱신 방법을 제공하고 있어서 입니다.
우선 쉘 스크립트 파일을 만듭니다. 크론 실행이 가장 안정적으로 작동하는 경우는 /bin 폴더에 쉘 스크립트 파일이 있는 경우라서 이 폴더에 쉘 스크립트 파일을 만듭니다.
cd /bin sudo vim letsencrypt.sh
여기에 아래와 같은 내용을 추가합니다.
#!/bin/sh sudo service nginx stop sudo certbot renew > /home/pi/Desktop/le_renew.log fuser -k 80/tcp sudo service nginx start
이 자동 쉘 스크립트 파일에 권한을 부여합니다.
sudo chmod +x letsencrypt.sh
이어 크론탭을 열어 편집 상태로 만듭니다.
sudo crontab -e
아래처럼 일정 시간마다 반복 작업하도록 배치잡을 등록합니다
30 4 * * 0 letsencrypt.sh
저장하고 나와서는 크론을 다시 실행 시킵니다.
sudo service cron start
멀티 도메인은 자동갱신 안됨
https://note.redgoose.me/article/2825/
수동으로 해야함
1.도메인 정보 및 만료일 확인
sudo letsencrypt certificates
2.인증서 갱신
certbot certonly --manual --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory -d goodzz.shop -d *.goodzz.shop
위 명령어 입력 후 DNS TXT 확인해서 도메인 업체 DNS 설정 > 레코드 수정에서 추가 해줘야함. 총 2번.
도메인 업체 DNS에 반영이 잘 됐는지 확인 후 엔터 치고 다음으로 넘어가야함
root@minhwan-server:/home/ubuntu# certbot certonly --manual --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory -d goodzz.shop -d *.goodzz.shop Saving debug log to /var/log/letsencrypt/letsencrypt.log Renewing an existing certificate for goodzz.shop and *.goodzz.shop - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please deploy a DNS TXT record under the name: _acme-challenge.goodzz.shop. with the following value: dxQj-E4HwPk2UDjBKIB9DnltcTvIhHYB9aotqoH15e0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Press Enter to Continue - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please deploy a DNS TXT record under the name: _acme-challenge.goodzz.shop. with the following value: GMun328Nj2IGGXosmMuP8uE5q_F8MNdrw5EuTsdsMlQ (This must be set up in addition to the previous challenges; do not remove, replace, or undo the previous challenge tasks yet. Note that you might be asked to create multiple distinct TXT records with the same name. This is permitted by DNS standards.) Before continuing, verify the TXT record has been deployed. Depending on the DNS provider, this may take some time, from a few seconds to multiple minutes. You can check if it has finished deploying with aid of online tools, such as the Google Admin Toolbox: https://toolbox.googleapps.com/apps/dig/#TXT/_acme-challenge.goodzz.shop. Look for one or more bolded line(s) below the line ';ANSWER'. It should show the value(s) you've just added. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Press Enter to Continue Successfully received certificate. Certificate is saved at: /etc/letsencrypt/live/goodzz.shop/fullchain.pem Key is saved at: /etc/letsencrypt/live/goodzz.shop/privkey.pem This certificate expires on 2024-06-30. These files will be updated when the certificate renews. NEXT STEPS: - This certificate will not be renewed automatically. Autorenewal of --manual certificates requires the use of an authentication hook script (--manual-auth-hook) but one was not provided. To renew this certificate, repeat this same certbot command before the certificate's expiry date. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - root@minhwan-server:/home/ubuntu#