Let’s Encrypt 인증서 발급 Ubuntu 18.04LTS(Apache2.4)

이번에는, Wild Card 인증서가 아닌 호스트마다 발급하는 일반적인 인증서 발급절차에 대해 알아 보자. Crontab을 통해 자동갱신도 할 수 있고 여러모로 편리하다. 굳이 힘들게 도메인 인증을 통한 Wild Card 인증은 필요 없을 듯하다. 수많은 서브사이트 생성이 아니라면 말이다.

1. 인증서 발급 어플인 Certbot를 설치해 줍니다. 먼저, 해당 앱을 설치하기 위한 PPA(Personal Package Archive)를 등록해 주고 설치 준비를 합니다.

root@vhubt1802:/home/joongon# apt update
root@vhubt1802:/home/joongon# apt install software-properties-common 
root@vhubt1802:/home/joongon# add-apt-repository universe
root@vhubt1802:/home/joongon# add-apt-repository ppa:certbot/certbot
root@vhubt1802:/home/joongon# apt update
root@vhubt1802:/home/joongon# apt install certbot python-certbot-apache

2. 아래 명령어를 통해 인증서 발급 신청을 진행 한다. ‘certonly’ 옵션으로 인증서만 설치한다.

*certonly 옵셥이 없을 경우, certbot에서 apache 설정을 자동으로 해주지만, 뭔가 찝찝하다.

root@vhubt1802:/home/joongon# certbot certonly --apache

2.1 email 주소를 물어본다. 적당히 입력해 준다.

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): joongonrigid@gmail.com

2.2 약관에 대한 동의 여부, (A)gree를 선택하고 진행한다.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

2.3 이메일 주소를 공유하겠느냐의 동의여부이다. 맘대로 하면 된다.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

2.4 본격적인 도메인에 대한 인증서 신청 화면이다. 필요한 도메인을 호스트주소와 함께 입력한다.

No names were found in your configuration files. Please enter in your domain
name(s) (comma and/or space separated)  (Enter 'c' to cancel): www.joongon.com 

2.5 발급되는 과정이다….

Obtaining a new certificate
Performing the following challenges:
http-01 challenge for www.joongon.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/www.joongon.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/www.joongon.com/privkey.pem
   Your cert will expire on 2020-07-17. 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 Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

3. 발급받은 인증서는 Crontab을 통해 자동 갱신되게 설정 되고, 이제 Apache Web Server에 해당 인증서를 적용하기만 하면 된다.

3.1 Apache2 기본 SSL 설정 파일을 복사해서 적용할 Site의 설정파일을 생성한다.

root@vhubt1802:/home/joongon# cp /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-available/joongon-ssl.conf

3.2 Site 설정파일을 nano 편집기로 오픈한다.

root@vhubt1802:/home/joongon# nano /etc/apache2/sites-available/joongon-ssl.conf

3.3 아래와 같이 ServerName 및 Letsencrypt 인증서 위치를 지정해준다

<IfModule mod_ssl.c>


        <VirtualHost *:443>

                ServerAdmin joongonrigid@gmail.com

                ServerName www.joongon.com
                ServerAlias www.joongon.com

                DocumentRoot /var/www/html


                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined

                SSLEngine on

                SSLCertificateFile /etc/letsencrypt/live/www.joongon.com/fullchain.pem
                SSLCertificateKeyFile /etc/letsencrypt/live/www.joongon.com/privkey.pem

                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>


        </VirtualHost>

</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

3.4 설정을 저장하고 설정파일을 활성화한다.(Symbolic Link), 그리고 apache를 재실행한다.

root@vhubt1802:/home/joongon# a2enmod ssl
Considering dependency setenvif for ssl:
Module setenvif already enabled
Considering dependency mime for ssl:
Module mime already enabled
Considering dependency socache_shmcb for ssl:
Enabling module socache_shmcb.
Enabling module ssl.
See /usr/share/doc/apache2/README.Debian.gz on how to configure SSL and create self-signed certificates.
To activate the new configuration, you need to run:
  systemctl restart apache2
root@vhubt1802:/home/joongon# a2ensite joongon-ssl.conf
Enabling site joongon-ssl.
To activate the new configuration, you need to run:
  systemctl reload apache2
root@vhubt1802:/home/joongon# systemctl restart apache2

3.5 설정 파일에 Symbolic Link가 설정된 것을 알 수 있다.

root@vhubt1802:/home/joongon# cd /etc/apache2/sites-enabled root@vhubt1802:/etc/apache2/sites-enabled# ls 000-default.conf joongon-ssl.conf root@vhubt1802:/etc/apache2/sites-enabled# sl -la Command 'sl' not found, but can be installed with: apt install sl root@vhubt1802:/etc/apache2/sites-enabled# ls -la total 8 drwxr-xr-x 2 root root 4096 Apr 18 15:43 . drwxr-xr-x 8 root root 4096 Apr 18 15:21 .. lrwxrwxrwx 1 root root 35 Apr 18 03:45 000-default.conf -> ../sites-available/000-default.conf lrwxrwxrwx 1 root root 35 Apr 18 15:43 joongon-ssl.conf -> ../sites-available/joongon-ssl.conf root@vhubt1802:/etc/apache2/sites-enabled#

4. 방화벽 설정을 해주고(port 443 open) 접속해보면 정상 작동함을 알 수 있다.

No comments to show.

Be the first to comment on "Let’s Encrypt 인증서 발급 Ubuntu 18.04LTS(Apache2.4)"

Leave a comment

Your email address will not be published.


*