(15-deprecated)AWS(아마존 웹서비스) 홈페이지 만들기 CentOS 7(Linux 7) 무료SSL증명서(Let’s Encrypt)작성하기

웹서비스구축

Certbot의 인증서 취득 방법이 변경 되었습니다. certbot-auto를 사용하면 다음과 같은 경고 메세지가 표시되고 다른 취득 방법을 위해서 공식 사이트를 방문하도록 안내하고 있습니다.

sudo /usr/bin/certbot-auto renew –post-hook “sudo systemctl restart httpd”
Your system is not supported by certbot-auto anymore.
certbot-auto and its Certbot installation will no longer receive updates.
You will not receive any bug fixes including those fixing server compatibility
or security problems.
Please visit https://certbot.eff.org/ to check for other alternatives.

이 글은 더 이상 유효하지 않지만 과거 글로 남겨 놓겠습니다.

새로운 인증서 취득 방법을 다음 글을 참조하십시오

눈깨비 정보창고 - 분기탱천
마우스 영역 지정 이미지 캡처를 문자 인식 및 번역하기 버튼 클릭 만으로  을 실행 해 주는 소프트웨어를 작성 했습니다. 자세한 도움말은 여기를 참조 하십시오. 웹 서비스 구축 눈깨비가 본업으로 하고 있는 기술적인 ...

참고로 이 글은 AWS 웹 서비스 환경 작성을 위한 글 목록의 일부이지만 제공 업체(Azuru, GCP등)가 다르더라도 Linux 7 운영 체제라면 이 글의 내용을 적용할 수 있습니다.


Let’s Encrypt란?

미국의 비영리단체에서 제공하는 90일간 유효한 무료 DV(Domain Validation) ssl증명서입니다. 2가지 인증방식(도메인인증, DNS인증)을 제공하고 있으며 ACME(Automated Certificate Management Environment) 프로토콜의 자동화 수법을 사용하기에 OS에서 커맨드실행으로 수 초만에 ssl증명서를 얻을 수 있습니다.

여담이지만 무료증명서를 제공하는 곳은 비영리단체이기에 운영에 필요한 자금을 얻기 위한 기부를 요청하고 있으며 관심있다면 한번 검토해보세요. Let’s Encrypt(Free SSL/TLSCertificates)에 기부하기

Let’s Encrypt 설치

curl 명령을 사용하여 certbot-auto스크립트 명령을 지정장소에 파일로 저장해서 실행할 수 있도록 파일 속성을 바꿔 놓습니다.

$ sudo curl https://dl.eff.org/certbot-auto -o /usr/bin/certbot-auto 
$ sudo chmod 700 /usr/bin/certbot-auto 

증명서 작성

certbot-auto스크립트 명령을 실행하여 지정 도메인(예:sample.com , www.sample.com)의 증명서를 만듭니다.

$ sudo /usr/bin/certbot-auto certonly --webroot -w /var/www/wordpress --debug -d sample.com -d www.sample.com

(주의)동일 도메인에 대해서 주내 5회 이상 사용하면 사용 제한을 당할 수 있습니다.

Apache 설정 파일 변경

$ sudo vi /etc/httpd/conf.d/ssl.conf
#SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateFile /etc/letsencrypt/live/www.sample.com/cert.pem
#SSLCertificateKeyFile SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
/etc/letsencrypt/live/www.sample.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/www.sample.com/chain.pem
SSLCertificateFile 
$ sudo systemctl restart httpd

자동 암화화접속 변환

강제적으로 보안 통신(암호화)으로 전환하려면 리다이렉트 방식을 사용하여 사용자의 http 접속 요청을 https 접속으로 바꿔야 합니다.
이 설정으로 웹사이트의 url이 http://로 접속하더라도 https://로 재접속되어 보안 경고가 보이지 않게 됩니다.

다음과 같이 https가 아닐 경우 https에 301 리다이렉트를 지시하도록 .htaccess를 작성합니다.

$ sudo vi /var/www/wordpress/.htaccess

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

증명서를 삭제하는 경우

도메인을 변경하거나 증명서 설정이 필요 없는 경우, 다음과 같이 삭제할 수 있습니다.

$ sudo /usr/bin/certbot-auto delete -d sample.com -d www.sample.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Which certificate(s) would you like to delete?
------------------------------------------------------------
1: www.sample.com
2: sample.com
------------------------------------------------------------
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1,2
------------------------------------------------------------
Deleted all files relating to certificate www.sample.com.
------------------------------------------------------------
------------------------------------------------------------
Deleted all files relating to certificate sample.com.
------------------------------------------------------------

증명서가 삭제되면 다음과 같이 Apache 설정 파일에서 증명서를 주석으로 처리합니다.

$ sudo vi /etc/httpd/conf.d/ssl.conf
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
#SSLCertificateFile /etc/letsencrypt/live/www.sample.com/cert.pem
SSLCertificateKeyFile SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
#SSLCertificateKeyFile /etc/letsencrypt/live/www.sample.com/privkey.pem
#SSLCertificateChainFile /etc/letsencrypt/live/www.sample.com/chain.pem

Apache 설정 파일을 적용하기 위해 다음과 같이 httpd 서비스를 재기동합니다.

$ sudo systemctl restart httpd

AWS 웹 서비스 환경 구축 전체 목록

이 글은 AWS 웹 서비스 환경 작성을 위한 전체 절차의 한 부분입니다. 전체 목록은 다음을 참조하십시오.

AWS EC2 웹 서비스(Wordpress) 구축 전체 글 목록
EC2(Elastic Compute Cloud) 웹 서비스 구축 전체 글 워드프레스 설치 , 환경 설정 전체 글
제목과 URL을 복사했습니다