티스토리 뷰
우분투 서버에 Let’s Encrypt의 무료 SSL 인증서를 설치하여 https를 적용한다.
Let’s Encrypt 인증서는 무료인 만큼 3개월 단위로 갱신하여야 한다.
하지만 자동 갱신 설정을 추가하여 계속 사용할 수 있도록 한다.
1. Certbot 설치
certbot과 python3-certbot-apache 패키지를 설치한다. 후자는 certbot의 apache 플러그인이다.
sudo apt install certbot python3-certbot-apache
2. SSL 인증서 발급
certbot은 플러그인을 통해 쉽게 SSL인증서를 발급받을 수 있도록 한다.
아파치 플러그인을 사용하면 아파치 설정을 알아서 해결해 준다.
sudo certbot --apache
이렇게 아파치에 설정된 도메인을 알아서 불러와 어떤 도메인에 인증서를 적용할지 물어본다.
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: my-domain.com
2: www.my-domain.com
3: my-domain.co.kr
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel):
원하는 번호를 입력해 인증서를 발급하자.
Requesting a certificate for my-domain.com
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/my-domain.com/fullchain.pem
Key is saved at: /etc/letsencrypt/live/my-domain.com/privkey.pem
This certificate expires on 2023-08-21.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.
Deploying certificate
Successfully deployed certificate for my-domain.com to /etc/apache2/sites-available/my-domain.com-le-ssl.conf
Congratulations! You have successfully enabled HTTPS on https://my-domain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
인증서 발급과 아파치 설정이 모두 완료되었다는 메시지가 나온다. 이제 브라우저를 통해 https로 접속해 보면 정상적으로 접속되는것을 볼 수 있다.
3. 자동갱신
처음에 언급한것 처럼 Let’s Encrypt 인증서는 무료인 만큼 3개월 단위로 갱신하여야 한다. 하지만 위의 메시지를 자세히 살펴보면 방급 발급된 인증서의 갱신 작업이 자동으로 스케줄 되었음을 알 수 있다. 다음과 같이 입력하여 확인해 보자.
sudo systemctl status certbot.timer
다음과 비슷한 결과가 출력될 것이다.
● certbot.timer - Run certbot twice daily
Loaded: loaded (/lib/systemd/system/certbot.timer; enabled; vendor preset: enabled)
Active: active (waiting) since Tue 2023-05-23 13:31:54 KST; 3h 18min ago
Trigger: Tue 2023-05-23 18:53:28 KST; 2h 3min left
Triggers: ● certbot.service
5월 23 13:31:54 MySystem systemd[1]: Started Run certbot twice daily.
하루에 두번씩 체크하여 30일 이내에 만료되는 인증서는 자동으로 갱신해 준다.
자동 갱신 테스트는 다음과 같이 실행해 볼 수 있다.
sudo certbot renew --dry-run
4. 삭제
◇ 인증서 목록 확인
ubuntu@:~$ sudo certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
Certificate Name: yunamom.duckdns.org
Domains: yunamom.duckdns.org
Expiry Date: 2022-04-17 23:33:36+00:00 (INVALID: EXPIRED)
Certificate Path: /etc/letsencrypt/live/yunamom.duckdns.org/fullchain.pem
Private Key Path: /etc/letsencrypt/live/yunamom.duckdns.org/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
◇ 인증서 삭제 하기
ubuntu@:~$ sudo certbot delete
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Which certificate(s) would you like to delete?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: yunamom.duckdns.org
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Deleted all files relating to certificate yunamom.duckdns.org.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
◇ 인증서 목록 확인
ubuntu@:~$ sudo certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
No certs found.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ubuntu@:~$
'SERVER' 카테고리의 다른 글
리눅스에 설치된 모든 하드디스크 정보 확인 명령어 (0) | 2025.01.29 |
---|---|
리다이렉션 URL 주소 바뀌지 않도록 하려면... (0) | 2024.11.03 |
ubuntu(우분투) 방화벽 설정 하기 (0) | 2024.10.19 |
.htaccess 리다이렉션 처리 하기 (0) | 2024.01.14 |
[그누보드] IE로 접속하면 특정 페이지로 이동시키기 (0) | 2023.04.02 |
댓글
Blog is Powered by 2011
DEVLUV