반응형

이 글은 nginx, python이 모두 설치되어 있고 도메인을 가지고 있는 상태에서 따라하시면 됩니다.


테스트 환경

  • AWS EC2 (Ubuntu 16.04.6 LTS)
  • nginx/1.10.3
  • Python 2.7.12

1. Certbot 설치하기

  • apt에 repository를 추가해줍니다.

    • $ sudo add-apt-repository ppa:certbot/certbot
  • apt를 업데이트 해줍니다.

    • $ sudo apt-get update
  • python-certbot-nginx 를 설치해줍니다.

    • $ sudo apt-get install python-certbot-nginx

2. nginx 설정에 도메인을 설정하기

  • $ sudo vi etc/nginx/sites-available/default

    • 설정파일을 에디터로 열어서 server_name 부분에 준비해둔 도메인을 써줍니다.
    ...
    server_name ex.com www.ex.com;
    ...
  • nginx 데몬을 재실행합니다.

    • $ sudo systemctl reload nginx

3. SSL 인증 설정하기

  • $ sudo certbot --nginx -d ex.com -d www.ex.com

  • 위 명령어를 실행하고 오류가 나지 않는다면 아래와 같은 출려이 나올 것이다.

    Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
    -------------------------------------------------------------------------------
    1: No redirect - Make no further changes to the webserver configuration.
    2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
    new sites, or if you're confident your site works on HTTPS. You can undo this
    change by editing your web server's configuration.
    -------------------------------------------------------------------------------
    Select the appropriate number [1-2] then [enter] (press 'c' to cancel):
    • 1번과 2번 중 원하는 옵션을 선택한다.
  • 완료

    IMPORTANT NOTES:
     - Congratulations! Your certificate and chain have been saved at
     .... 생략 .....
    • 기분좋은 Congratulations!를 본다면 성공한 것이다.
    • 이제 도메인으로 접속을 해보면 주소 옆에 자물쇠가 뜨고 자동으로 https가 적용되는 것을 확인할 수 있다.
반응형

BELATED ARTICLES

more