Ubuntu 에서 Let’s Encrypt 인증서 다시연결(갱신, 재설정)

1) 인증서가 만료되었거나 다시 연결해야 하는 경우

가장 일반적인 방법은 certbot renew 또는 재발급(certonly) 입니다.

● 인증서 갱신(renew)

sudo certbot renew

자동 갱신이 잘 되는지 테스트:

sudo certbot renew --dry-run

(갱신 로직은 Ubuntu에서 자동 스케줄러로 하루 2번 실행됨)


2) 인증서를 새로 발급해서 다시 연결해야 하는 경우

도메인 연결이 바뀌었거나, 설정을 다시 해야 한다면 certonly로 재발급합니다.

● Nginx

sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

● Apache

sudo certbot --apache -d yourdomain.com -d www.yourdomain.com

● Webroot 방식

sudo certbot certonly --webroot -w /var/www/html -d yourdomain.com

3) 인증서 파일을 웹서버에 다시 연결해야 하는 경우

Let’s Encrypt 인증서는 아래 경로에 저장됩니다:

/etc/letsencrypt/live/도메인명/
  ├─ cert.pem
  ├─ privkey.pem
  ├─ chain.pem
  └─ fullchain.pem

● Nginx 설정 예시

ssl_certificate     /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;

● Apache 설정 예시

SSLCertificateFile /etc/letsencrypt/live/yourdomain.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/yourdomain.com/privkey.pem

설정 후 웹서버 재시작:

sudo systemctl restart nginx
# 또는
sudo systemctl restart apache2

4) 인증서 갱신 후 자동 reload 설정(Nginx)

Certbot은 인증서를 갱신해도 Nginx가 자동 reload 되지 않을 수 있습니다.
이 경우 deploy hook을 추가합니다.

sudo nano /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh

내용:

#!/bin/bash
systemctl reload nginx

권한 부여:

sudo chmod +x /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh

댓글 달기

위로 스크롤