1. 서버 진입 후 root 권한 취득
# 관리자 권한 취득 sudo su -
2. Lets Encrypt 데몬 설치
# certbot 설치여부 확인 yum list certbot # certbot 없으면 설치 yum install -y certbot
3. Lets Encrypt 인증서 설치
# 인증서 설치 (도메인 정보만 넣으면 자동으로 발급부터 세팅까지) certbot certonly --manual --agree-tos --preferred-challenges=dns --server https://acme-v02.api.letsencrypt.org/directory --email myid@gmail.com --domains *.qnibus.com # 결과 출력화면 Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator manual, Installer None Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org Requesting a certificate for *.qnibus.com Performing the following challenges: dns-01 challenge for qnibus.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please deploy a DNS TXT record under the name _acme-challenge.qnibus.com with the following value: zR8Hja5rvnHTSpHiX9fZztoflGTxCkN4iDAEUiSz-5w Before continuing, verify the record is deployed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Press Enter to Continue
4. DNS TXT 레코드 설정
- 내 도메인 관리 사이트로 이동하여 DNS레코드 설정을 하자.
- 위 인증서 설치시 나오는 문구로 TXT 레코드 설정
_acme-challenge.qnibus.com. 3600 IN” TXT zR8Hja5rvnHTSpHiX9fZztoflGTxCkN4iDAEUiSz-5w
5. Enter키 입력 (Press Enter to Continue)
Waiting for verification... Cleaning up callenges IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/qnibus.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/qnibus.com/privkey.pem Your certificate will expire on 2022-01-30. To obtain a new or tweaked version of this certificate in the future, simply run certbot again. To non-interactively renew *all* of your certificates, run "certbot renew" - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encyrpt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
6. 인증서 설치완료
- 설치 후 아래 디렉토리로 이동하면 신규 설치 도메인 경로가 보임
cd /etc/letsencrypt/livelltotal 7drwxr-xr-x 3 root root 104 Aug 2 19:09 qnibus.com -rw-r--r-- 1 root root 740 Aug 2 17:43 README
7. 보안서버 설정을 위한 파일 변환 및 이동
# 생성된 인증서 디렉토리 이동 cd qnibus.com # 리스트 확인 ll total 4 lrwxrwxrwx 1 root root 35 Aug 2 17:43 cert.pem -> ../../archive/godo5.co.kr/cert1.pem lrwxrwxrwx 1 root root 36 Aug 2 17:43 chain.pem -> ../../archive/godo5.co.kr/chain1.pem lrwxrwxrwx 1 root root 40 Aug 2 17:43 fullchain.pem -> ../../archive/godo5.co.kr/fullchain1.pem lrwxrwxrwx 1 root root 38 Aug 2 17:43 privkey.pem -> ../../archive/godo5.co.kr/privkey1.pem -rw-r--r-- 1 root root 692 Aug 2 17:43 README # 아래는 다른 형식으로 변환하여 저장시 사용하면 됨 # key 파일 변환 (내부 규칙대로 파일 저장시 사용) openssl rsa -in privkey.pem -text > /usr/local/apache/ssl/conf/ssl.key/LE.qnibus.com.key # crt 파일 변환 (내부 규칙대로 파일 저장시 사용) openssl x509 -inform PEM -in fullchain.pem -out /usr/local/apache/ssl/conf/ssl.crt/LE.qnibus.com.crt # fullchain.pem 복사 (내부 규칙대로 파일 저장시 사용) cp fullchain.pem /usr/local/apache/ssl/conf/ssl.pem/LE.qnibus.com.pem
8. SSL 환경설정 (PC/모바일/관리자/API)
cd /usr/local/apache/conf/extra
vi httpd.vhost.conf
<VirtualHost *:443>
DocumentRoot "/home/qnibus.com"
ServerName www.qnibus.com
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:!RC4!RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /etc/letsencrypt/live/qnibus.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/qnibus.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/qnibus.com/fullchain.pem
<FilesMatch "\.([Jj][Pp][Gg]|[Jj][Pp][Ee][Gg]|[Gg][Ii][Ff]|[Pp][Nn][Gg]|[Bb][Mm][Pp]|[Aa][Vv][Ii]|[Mm][Pp][Ee][Gg]|[Zz][Ii][Pp]|[Zz][00-99]|[Rr][Aa][Rr]|[Mm][Pp][1-9]|[Aa][Rr][Jj]|[Ee][Xx][Ee]|[Aa][Ss][Ff]|[Ww][Mm][a-z]*|[Rr][Aa][a-z]*|[Aa][Il][Zz]|[Zz][00-99])$">
SetEnvIF Referer www\.qnibus\.com link_allow
SetEnvIF Referer qnibus\.com link_allow
SetEnvIFNoCase Referer ^$ link_allow
Order Deny,Allow
Allow from env=link_allow
Deny from all
</FilesMatch>
</VirtualHost>
9. 보안서버 재시작
# 설정 검사 /etc/init.d/httpd -t OK # 재시작 /etc/init.d/httpd -k restart /etc/rc.d/init.d/httpd graceful
참고. Crontab 등록
- 없는 경우만 추가하면 되며, 있는 경우 자동으로 인증서 갱신처리 됨
crontab -e # 매월 29일 새벽 3시 실행 0 3 29 * * /usr/bin/certbot renew --renew-hook="/etc/rc.d/init.d/httpd_ssl graceful"
참고. 인증서 삭제방법
certbot -auto delete Saving debug log to /var/log/letsencrypt/letsencrypt.log Which certificate(s) would you like to delete? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: qnibus.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shown (Enter 'c' to cancel): 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The following certificate(s) are selected for deletion: * qnibus.com Are you sure you want to delete the above certificate(s)? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y Deleted all files relating to certificate qnibus.com.
참고. 인증서 갱신방법
인증서 생성시 -manual 옵션 사용하는 경우 auto-renew가 작동하지 않음
*.domain.com의 경우 -manual로 생성하지 않으면 안되는 부분이고, DNS Verify 자체를 certbot이 못하는 이유라고 함
- 참고. 인증서 삭제방법을 통해 갱신하고자 하는 인증서 제거
- 신규로 생각하고 위 3~7까지 진행
- 아파치 graceful 진행
- 완료
No responses yet