반응형

CertBot
Let's Encrypt 무료 인증서 자동 발급 프로그램.
실행 조건
- Domain이 정상적으로 생성되어 있으며, 해당 도메인을 소유하고 있어야 함.
- Linux 동작. (Windows에서는 테스트 X)
유의사항
아래의 자료는 CentOS 8 기준으로 작성됨. (CentOS 7 이상은 원활하게 작동될 것으로 예상)
CertBot 설치
# Extra Packages for Enterprise Linux 설치
yum install epel-release
# CertBot 설치
yum install certbot
# NGINX 호환 모듈 설치
yum install python3-certbot-nginx
HTTPS(SSL) 설정
HTTPS 인증서 설치 시 여러 작업 방식이 존재
NGINX에 Domain 설정
Nginx.conf 또는 conf.d 폴더에 *.conf 형식으로 도메인이 미리 선언되어야함.
(일반 http:80만 선언되어 있어야 함. https:443 선언 존재 시 충돌 가능성 있음)
# Sample Config
server {
listen 80 ;
listen [::]:80 ;
server_name admin.dev.kr;
location / {
proxy_pass https://proxy_webserver;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
sudo certbot --nginx
:기본
별도의 작업 없이 NGINX config 설정까지 동시에 진행하는 명령어
# certbot --nginx -d [Domain Name] --no-eff-email --agree-tos -m [Admin Email]
certbot --nginx -d admin.dev.kr --no-eff-email --agree-tos -m Admin@gmail.com
--no-eff-email
: Let's Encrypt 이메일을 받지 않음--agree-tos
: 각종 체크 항목 전체 승인-m
: 관리자 이메일 지정
:STANDALONE
NGINX 서비스를 이용하여 발급.
NGINX 서비스를 내리고 실행해야 함으로 서비스를 내리지 못할 시 사용 불가
해당 작업 시 Nginx Config를 수동으로 수정해야 함
# certbot certonly --standalone -d [Domain Name] --no-eff-email --agree-tos -m [Admin Email]
certbot certonly --standalone -d admin.dev.kr --no-eff-email --agree-tos -m Admin@gmail.com
작업 후 Nginx Config
# Sample Config
server {
server_name admin.dev.kr;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
proxy_pass https://proxy_webserver;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/admin.dev.kr/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/admin.dev.kr/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 = admin.dev.kr) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 ;
listen [::]:80 ;
server_name admin.dev.kr;
return 404; # managed by Certbot
}
자동 갱신
갱신 테스트
certbot renew --dry-run
갱신 명령어
certbot renew
--pre-hook "nginx -s stop" --post-hook "nginx"
Crontab 스케줄러 설정
# Crontab config 편집기 실행
sudo crontab -e
# 아래 명령어 추가
# 매월 1일 00:00 실행 설정
0 0 1 * * /usr/local/bin/certbot renew --pre-hook "nginx -s stop" --post-hook "nginx"
분기 설정 참조 : crontab.guru
SSL 평가 Site
SSL Server Test (Powered by Qualys SSL Labs)
SSL Server Test This free online service performs a deep analysis of the configuration of any SSL web server on the public Internet. Please note that the information you submit here is used only to provide you the service. We don't use the domain names or
www.ssllabs.com
반응형
'OS > Linux' 카테고리의 다른 글
[Linux] 자동 로그아웃 설정 (0) | 2021.07.21 |
---|---|
[Linux] ping 차단 (0) | 2021.07.21 |
[Linux] OpenSSL - Root CA 생성 및 SSL 인증서 발급 (0) | 2020.09.21 |
[Linux] CentOS 8 firewalld 설치 및 사용법 (0) | 2020.04.06 |
[Linux] CentOS 8 firewalld 비활성화 / iptables 활성화 (0) | 2020.04.06 |