Let's Encrypt(Certbot)로 무료 SSL 인증서 발급하는 방법
1. Standalone 모드(웹 서버가 없는 경우)
웹 서버 없이 Certbot이 자체적으로 임시 웹 서버를 실행해 인증을 처리하는 방식입니다.
특징
- 기존 웹 서버가 없을 때 사용
- 포트 80(HTTP) 또는 443(HTTPS) 가 열려 있어야 함
- 임시 서버 구동 → 인증 → 자동 종료
사전 준비
- 방화벽에서 80/443 포트 오픈
- 도메인이 서버 IP로 연결되어 있어야 함(A 레코드 설정)
명령어 예시
certbot certonly --standalone -d [도메인명1] -d [도메인명2]
certbot certonly --standalone -d example.com -d www.example.com
Certbot은 자체 HTTP 서버를 실행하여 Let's Encrypt의 ACME 서버와 통신하고, 인증 후 자동으로 종료됩니다.
2. Webroot 모드(운영 중인 웹 서버가 있는 경우)
웹 서버를 중단하지 않고 인증서를 발급할 수 있는 실무에서 가장 많이 사용되는 방식입니다.
특징
- 웹 서버 중단 없이 발급 가능
- 웹 서버 루트 디렉토리에 .well-known/acme-challenge 폴더 생성
- 자동 갱신 지원 (certbot renew)
사전 준비
- 웹 루트 경로 확인 (예: /var/www/html)
- 방화벽에서 80/443 포트 오픈 명령어 예시
명령어 예시
certbot certonly --webroot -w [접근 가능 경로] -d [도메인명1]
certbot certonly --webroot -w /var/www/html -d example.com -d www.example.com
certbot certonly --webroot \
--agree-tos --no-eff-email \
--email admin@sangchul.kr \
--webroot-path=/var/www/letsencrypt \
-d sangchul.kr
인증 과정에서 /.well-known/acme-challenge/ 경로 아래에 인증용 파일이 생성되며 Let's Encrypt가 이를 확인해 도메인 소유권을 검증합니다.
3. Manual 모드(DNS 또는 파일로 직접 인증)
DNS 레코드나 파일을 직접 생성해 도메인 소유권을 검증하는 수동 방식입니다. 자동 갱신이 불가능하므로 임시 테스트나 특수 환경에서 사용합니다.
특징
- 직접 DNS TXT 레코드 추가 필요
- 웹 서버 없이도 가능
- 자동 갱신 미지원
명령어 예시
certbot certonly --manual --preferred-challenges dns -d [도메인명1]
certbot certonly --manual -d example.com -d www.example.com
certbot certonly --manual \
--preferred-challenges dns \
--staging \
-d www.sangchul.kr
명령 실행 후 Certbot이 제시하는 TXT 레코드를 DNS에 추가한 뒤 인증이 완료되면 인증서가 발급됩니다.
4. Apache 모드(Apache 웹 서버 자동 설정)
Apache 환경이라면 Certbot이 설정까지 자동으로 처리합니다.
특징
- Apache 설정 자동 구성 및 적용
- 인증서 자동 갱신 및 설정 반영 가능
명령어 예시
certbot --apache -d example.com -d www.example.com
Certbot이 가상호스트 설정 파일을 수정하고 SSL 설정을 자동으로 적용합니다.
5. Nginx 모드(Nginx 자동 설정)
Nginx 웹 서버를 사용하는 경우에도 Certbot이 자동으로 인증서 설정을 구성합니다.
특징
- Nginx 설정 자동 업데이트
- 인증서 자동 갱신 시 설정 자동 반영
명령어 예시
certbot --nginx -d example.com -d www.example.com
nginx 모드에서도 Certbot은 nginx 설정 파일을 자동으로 수정하고 인증서를 발급받습니다.
Certbot 기본 명령어 요약
| 명령어 | 설명 |
| certbot certonly | 인증서만 발급 (설정은 수동) |
| certbot renew | 기존 인증서 자동 갱신 |
| certbot certificates | 현재 발급된 인증서 정보 확인 |
| certbot revoke | 인증서 폐기 |
| certbot delete | 인증서 삭제 |
| --standalone | 독립 서버 모드 |
| --webroot | 웹 루트 인증 모드 |
| --manual | 수동 인증 모드 |
| --apache | Apache 자동 설정 |
| --nginx | Nginx 자동 설정 |
certbot 도움말 보고
docker run -it --rm certbot/certbot --help
certbot [SUBCOMMAND] [options] [-d DOMAIN] [-d DOMAIN] ...
$ certbot --help
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
certbot [SUBCOMMAND] [options] [-d DOMAIN] [-d DOMAIN] ...
Certbot can obtain and install HTTPS/TLS/SSL certificates. By default,
it will attempt to use a webserver both for obtaining and installing the
certificate. The most common SUBCOMMANDS and flags are:
obtain, install, and renew certificates:
(default) run Obtain & install a certificate in your current webserver
certonly Obtain or renew a certificate, but do not install it
renew Renew all previously obtained certificates that are near
expiry
enhance Add security enhancements to your existing configuration
-d DOMAINS Comma-separated list of domains to obtain a certificate for
(the certbot apache plugin is not installed)
--standalone Run a standalone webserver for authentication
(the certbot nginx plugin is not installed)
--webroot Place files in a server's webroot folder for authentication
--manual Obtain certificates interactively, or using shell script
hooks
-n Run non-interactively
--test-cert Obtain a test certificate from a staging server
--dry-run Test "renew" or "certonly" without saving any certificates
to disk
manage certificates:
certificates Display information about certificates you have from Certbot
revoke Revoke a certificate (supply --cert-name or --cert-path)
delete Delete a certificate (supply --cert-name)
manage your account:
register Create an ACME account
unregister Deactivate an ACME account
update_account Update an ACME account
--agree-tos Agree to the ACME server's Subscriber Agreement
-m EMAIL Email address for important account notifications
More detailed help:
-h, --help [TOPIC] print this message, or detailed help on a topic;
the available TOPICS are:
all, automation, commands, paths, security, testing, or any of the
subcommands or plugins (certonly, renew, install, register, nginx,
apache, standalone, webroot, etc.)
-h all print a detailed help page including all topics
--version print the version number
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'리눅스' 카테고리의 다른 글
| [draft] cronolog를 컴파일하여 설치하고 로그를 설정하는 방법 (0) | 2025.10.24 |
|---|---|
| [draft] BIND 관리를 위한 RNDC 설정하는 방법 (0) | 2025.10.24 |
| [draft] 우분투 22.04에서 node와 npm을 설치하는 방법 (0) | 2025.10.24 |
| [draft] 우분투 22.04에서 node.js와 npm을 설치하는 방법 (0) | 2025.10.24 |
| [draft] 우분투에서 cowsay를 설치하고 설정하는 방법 (0) | 2025.10.24 |