Skip to content

Instantly share code, notes, and snippets.

@LeoHeo
Last active August 16, 2016 13:11
Show Gist options
  • Save LeoHeo/8196cb25eeb28f2cf96274363777c314 to your computer and use it in GitHub Desktop.
Save LeoHeo/8196cb25eeb28f2cf96274363777c314 to your computer and use it in GitHub Desktop.

ssl letsencrypt 세팅

letsencrypt-getting-started 참고 블로그

기본적으로 ssl 세팅을 할려면 도메인주소가 있어야 하며(권장), https default 443 port*가 열려있어야 한다.

그리고 EIP(Elastic IP)가 인스턴스에 Associate 되어 있다는 전제하에 설명을 한다.

일단 AWS Route53에 Hosted zone을 만들어 줘야 한다.

1.create hosted zone

2.생성되면 나오는 네임서버 주소들을 본인이 산 도메인 업체쪽에 네임서버에 세팅을 해준다.

3.created record set으로 value에 EIP를 적어준다.

그 다음에 아래와 같은 절차로 진행한다.

$ sudo service nginx stop
$ git clone https://github.com/letsencrypt/letsencrypt
$ cd letsencrypt
$ ./letsencrypt-auto --help
$ ./letsencrypt-auto certonly --standalone -d [your domain]

위 과정을 모두 마치면 /etc/letsencrypt/live/[your domain]/에 **2개(privkey, fullchain)**의 pem파일이 생성된다.

그 다음에 http로 요청오면 무조건 https로 redirect 되기 위해 nginx.conf 값을 아래와 같이 바꿔준다.

server{
  listen 80;
  ...
  return 301 https://$server_name$request_uri;
}

server {
  listen  443 default_server ssl;
}

여기서 포인트return 301 https://$server_name$request_uri;이다.

위와 같이 세팅하고 sudo service nginx restart하고 나서 접속해보면 사이트가 https로 설정된다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment