전 게시글에서
/etc/nginx/sites-available/dev.rp2airbnb.shop
을 만들어 주었다.
Certbot을 설치하기위해 먼저 업데이트를 한뒤 설치한다.
sudo apt update
sudo add-apt-repository ppa:certbot/certbot
다시 업데이트 후 Nginx 패키지를 설치한다.
sudo apt update
sudo apt install python-certbot-nginx
Nginx의 구성을 확인
sudo vi /etc/nginx/sites-available/dev.rp2airbnb.shop을 확인하여
서버 블록 안에 server_name dev.rp2airbnb.shop 으로 잘 설정이 되어있는지 확인한다.
수정하였다면 아래와 같이 실행시킨다.
sudo nginx -t
sudo systemctl reload nginx
SSL 인증서 받기
아래의 명령어로 Nginx 플러그인을 통하여 인증서를 얻을 수 있다.
sudo certbot --nginx -d dev.rp2airbnb.shop
여기서 선택의 길이 나온다.
1을 입력하면 HTTPS로 리다이렉트 하지않고 2로하여 HTTPS로 리다이렉트 해준다.
1입력시 http://dev.rp2airbnb.shop 를 해도 https://dev.rp2airbnb.shop 이되지 않는다.
2입력시 https://dev.rp2airbnb.shop 로 리다이렉트된다.
그리고 AWS 인스턴스의 인바운드 규칙에 가서 HTTPS 를 추가해준다.
이 사이트는 SSL인증이 되었는지 테스트하는 사이트다.
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
위와 같은 테스트 화면을 얻었다. 이렇게 된다면 인증이 완료된 것이다.
그 다음 도메인으로 접속을 해보면 보안연결이 잘 된것을 확인할 수 있다.
Let's Encrypt 인증서는 90일 동안 유효해서 갱신을 해줘야 하지만 위와 같은 설치과정을 통해 자동으로 갱신시켜주는 커멘드가 추가되었다.
자동으로 갱신을 시켜주는게 잘 동작하는지 확인하기 위해선 아래의 명령어를 입력한다.
sudo certbot renew --dry-run
참고
www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-18-04
How To Secure Nginx with Let's Encrypt on Ubuntu 18.04 | DigitalOcean
In this tutorial, we will show you how to use Let's Encrypt to obtain a free SSL certificate and use it with Nginx on Ubuntu 18.04. We will also show you how to automatically renew your SSL certificate. If you're running a different web server, simply
www.digitalocean.com
twpower.github.io/44-set-free-https-by-using-letsencrypt
'기타 > RP' 카테고리의 다른 글
[AWS] ec2 인스턴스 생성 (0) | 2021.07.01 |
---|---|
라이징 프로그래머 2기 수료 및 후기 (4) | 2021.04.23 |
메이커스(MakeUs) 6기 동아리 후기 (0) | 2021.04.21 |
정리해야 하는 것 (0) | 2021.04.12 |
도메인 연결과 서브 도메인 (0) | 2021.04.12 |