Certbot은 설치에 snap 패키지를 사용 할 것을 권장합니다.
snap 패키지는 거의 모든 linux 배포판에서 작동하지만 snapd 패키지를 관리하려면 먼저 snapd를 설치해야합니다. Ubuntu는 16.04버전부터 기본적으로 스냅을 지원하므로 snapd 코어가 최신상태인지 확인만 하면 됩니다.
sudo snap install core; sudo snap refresh core
sudo apt remove certbot
sudo snap install --classic certbot
(원문) Finally, you can link the certbot command from the snap install directory to your path, so you’ll be able to run it by just typing certbot. This isn’t necessary with all packages, but snaps tend to be less intrusive by default, so they don’t conflict with any other system packages by accident:
(우연히 다른패키지와 충돌할 경우를 피하기 위해?)
(certbot 명령어를 사용하기 위해?)
snap폴더에서 usr 폴더로 심볼릭 링크를 걸어줍니다.
sudo ln -s /snap/bin/certbot /usr/bin/certbot
nginx 설정파일에 도메인을 추가합니다.
( 기본경로 - /etc/nginx/sites-availavle/default )
server {
...
server_name example.com www.example.com;
...
}
sudo systemctl reload nginx
(ufw를 사용할 경우) 방화벽 상태를 확인합니다.
sudo ufw status
다음과 같거나 HTTPS(443) 포트가 열려 있지 않다면 HTTPS를 허용합니다.
Output
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Nginx HTTP ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Nginx HTTP (v6) ALLOW Anywhere (v6)
(Nginx Full은 HTTP와 HTTPS 포트를 열어줍니다. HTTP가 중복되므로 Nginx HTTP를 삭제해 줍니다.)
sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'
상태가 다음과 같은지 확인합니다
sudo ufw status
Certbot은 플러그인을 통해 다양한 방법으로 SSL 인증서를 얻을 수 있습니다. Nginx 플러그인은 Nginx 설정파일을 자동으로 설정해줍니다.
sudo certbot --nginx -d example.com -d www.example.com
(-d 뒤에 도메인을 입력 한 후 다시 -d 로 다른 도메인을 추가로 등록할 수 있습니다. 즉, 위 예시는 2개의 도메인을 등록하는 예시입니다.)
명령을 실행하면 이메일 주소를 입력하고 서비스 약관에 동의하라는 메시지가 표시됩니다. 그렇게 하면 프로세스가 성공했으며 인증서가 저장된 위치를 알려주는 메시지가 표시되어야 합니다.
(완료 메세지)
Output
IMPORTANT NOTES:
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/your_domain/fullchain.pem
Key is saved at: /etc/letsencrypt/live/your_domain/privkey.pem
This certificate expires on 2022-06-01.
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
Let's Encrypt의 인증서는 90일 동안만 유효합니다. 이는 사용자가 인증서 갱신 프로세스를 자동화하도록 권장하기 위한 것입니다. 우리가 설치 한 certbot패키지는 하루에 두 번 실행되고 만료 30일 이내에 인증서를 자동으로 갱신하는 시스템 타이머를 추가하여 이를 처리합니다.
(대충 위에 따라했다면 자동으로 갱신해준다는 뜻)
다음을 사용하여 타이머 상태를 쿼리할 수 있습니다
sudo systemctl status snap.certbot.renew.service
(잘 작동하는 화면)
Output
○ snap.certbot.renew.service - Service for snap application certbot.renew
Loaded: loaded (/etc/systemd/system/snap.certbot.renew.service; static)
Active: inactive (dead)
TriggeredBy: ● snap.certbot.renew.timer
자동갱신 프로세스를 테스트 하기 위해 다음을 실행하면 됩니다.
sudo certbot renew --dry-run
오류가 나지 않는다면 OK 입니다.