PostIT

[Server/SSL] Let's Encrypt로 SSL 적용하기 - 퍼옴 본문

Linux/Etc

[Server/SSL] Let's Encrypt로 SSL 적용하기 - 퍼옴

shun10114 2017. 3. 29. 13:35

https://blog.korsnack.kr/blog/post/lets-encrypt-with-nginx


nginx로 돌아가고 있는 서버에 Let's Encrypt를 적용시켜 보았다.

1. 설치


$ git clone https://github.com/letsencrypt/letsencrypt
$ cd letsencrypt
$ ./letsencrypt-auto \
  --help

git에서 repo를 clone한 뒤, 자체적으로 제공하는 스크립트를 이용하면 자동으로 환경이 설정된다.

2. 인증서 발급


먼저 nginx를 잠시 멈출 필요가 있다. Let's Encrypt(이하 LE) 스크립트 자체에서 웹 서버를 생성해서 이것저것 하는 것 같다.
번거롭지만 어쩔 수 없다.

$ service nginx stop

인증서를 발급한다.

$ ./letsencrypt-auto certonly \
  -a standalone \
  -d yourdomain.tld \
  -d www.yourdomain.tld

제대로 발급이 완료된 경우

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at
   /etc/letsencrypt/live/yourdomain.tld/fullchain.pem. Your cert will
   expire on 20xx-xx-xx. To obtain a new version of the certificate in
   the future, simply run Let's Encrypt again.

라는 메시지가 출력된다.

다시 nginx를 시작시킨 뒤, 제대로 발급 됐는지 확인.

$ service nginx start
$ ls /etc/letsencrypt/live/yourdomain.tld/
cert.pem  chain.pem  fullchain.pem  privkey.pem



3. nginx 설정 적용


필요한 vhost 블록에 아래를 적용시킨다.

listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/yourdomain.tld/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.tld/privkey.pem;
ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /etc/letsencrypt/live/yourdomain.tld/fullchain.pem;

설정이 제대로 들어갔는지 테스트를 한번 하고 적용시킨다.

$ nginx -t
$ service nginx reload



4. 인증서 갱신


LE에서 발급된 인증서는 90일간 유효하다. 따라서 주기적으로 갱신이 필요하다.
인증서를 발급했던 것과 비슷하게 nginx를 멈추고, 갱신하고, 다시 시작시킨다.

$ service nginx stop
$ ./letsencrypt-auto certonly --renew \
  -a standalone \
  -d yourdomain.tld \
  -d www.yourdomain.tld
$ service nginx start


nginx 설정 반영까지 한번에 되면 좋을텐데, 아쉽지만 별 수 있나.

Comments