728x90
- Certbot은 수동으로 관리하는 웹사이트에서 Let's Encrypt 인증서를 사용하여 HTTPS를 활성화하는 무료 오픈 소스 소프트웨어 도구입니다.
- Certbot은 60일 주기로 자동 업데이트를 진행하며, 아래 적용과정에서 자세히 설명하겠습니다.
Certbot으로 HTTPS를 적용하는 과정
1. Certbot 설치 (우분투 기준)
sudo apt update
sudo apt install certbot python3-certbot-nginx -y
2. 도메인 확인
ping [도메인명]
3. 인증서 발급
certbot
//nginx 설정을 자동으로 찾아 80포트에서 http 테스트, 인증서 발급 및 https 설정 nginx 적용
certbot --nginx -d [도메인명]
//여러 도메인을 한 번에 적용 시
certbot --nginx -d [도메인명1] -d [도메인명2]
4. 도메인 선택, https 설정 -> nginx conf 자동 적용
vi /etc/nginx/xxx.conf
.
.
.
#아래는 모두 Certbot으로 자동 수정된 내용
listen 443 ssl; # managed by Certbot
listen [::]:443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/[도메인명 디렉토리]/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/[도메인명 디렉토리]/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = [도메인명]) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name [도메인명];
listen 80;
listen [::]:80;
return 404; # managed by Certbot
}
5. nginx reload
nginx -t #유효성 검사
nginx -s reload #nginx conf 적용
6. https 적용 확인(인증서)
* 인증서 유효기간 확인법
certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
Certificate Name: [도메인명1]
Serial Number: 63a78b7aef581b7141f3260136026238c79
Key Type: ECDSA
Domains: [도메인명1]
Expiry Date: 2025-06-29 04:47:39+00:00 (VALID: 74 days)
Certificate Path: /etc/letsencrypt/live/[도메인명1]/fullchain.pem
Private Key Path: /etc/letsencrypt/live/[도메인명1]/privkey.pem
Certificate Name: [도메인명2]
Serial Number: 4a88ca0ebedcdb22861dd4515aca07ba109
Key Type: RSA
Domains: [도메인명2]
Expiry Date: 2024-07-21 15:36:37+00:00 (INVALID: EXPIRED)
Certificate Path: /etc/letsencrypt/live/[도메인명2]/fullchain.pem
Private Key Path: /etc/letsencrypt/live/[도메인명2]/privkey.pem
* 인증서 갱신 테스트 (실제 갱신 X)
certbot renew --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/[도메인명1].conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Account registered.
Simulating renewal of an existing certificate for [도메인명1]
.
.
.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The following simulated renewals succeeded:
/etc/letsencrypt/live/[도메인명1]/fullchain.pem (success)
* Certbot의 인증서는 기본적으로 자동 갱신된다. 만약 수동으로 일정을 조정하고 싶다면, crontab에 배치를 추가하는 등의 방법으로 진행해야 한다.
728x90
'OS > Linux' 카테고리의 다른 글
[Linux] top 명령어 옵션 (0) | 2025.04.11 |
---|---|
[putty] SSH 접속 유지 설정법 (0) | 2025.04.09 |
[Linux] CentOS SSH 로그인 시 느려지는 현상 해결법 (1) | 2025.04.08 |
[Linux] 네트워크 관련 명령어 및 옵션 (0) | 2024.10.29 |
[Linux] 리눅스마스터 1급 필기 기출 (14) | 2024.10.16 |