SSL 셋팅을위한 EC생성 및 nginx 설치 도메인 연결
sudo apt -y update
sudo apt -y install nginx
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
vi /etc/nginx/sites-available/default
systemctl restart nginx
nginx -t
sudo certbot --nginx
certbot --nginx -d cl.oud.kr
로드벨런싱을 위해 서버를 증설할떄 보안서버도 다시 생성하는게 아니라 기존 키파일을 가져가면된다
certbot에서 수정한 곳을 확인하면 설정파일들이 있는데 이걸 똑같이 가져가주면된다.
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /root/cl.oud.kr_ssl/fullchain.pem; # managed by Certbot
ssl_certificate_key /root/cl.oud.kr_ssl/privkey.pem; # managed by Certbot
include /root/cl.oud.kr_ssl/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /root/cl.oud.kr_ssl/ssl-dhparams.pem; # managed by Certbot
cert.pem : yourdomain.com 의 인증서 (public key)
chain.pem : Let’s encrypt의 Intermediate 인증서.
fullchain.pem : cert.pem 과 chain.pem을 합친 결과
privkey.pem : cert.pem publickey에 대응하는 비밀키
DNS로도 로드벨런싱이 가능하다는걸 알수있었다.
이번엔 AWS 인증서버를 사용하자
https://ap-northeast-2.console.aws.amazon.com/acm
https://ap-northeast-2.console.aws.amazon.com/acm/home
ap-northeast-2.console.aws.amazon.com
자기 도메인을 AWS에 등록한다
DNS검증을통해 CNAME로 검증해서 도메인이 본인소유임을 확인시켜준다.
AWS인증서는
에서 사용가능하기때문에 EC2두개를 ELB에 연결한다.
ELB대상그룹 생성해서 EC2두개 넣는다.
로드벨런서의 리스너두개 생성
80 , 443 두개다 그룹은 같은걸로 생성하고 추후 80의 리스터 규칙을 443으로 리다이렉트로 변경
이건 바꾸기전 설정이다
80 > 로드벨런서 > 엔진엑스 > 443 > 로드벨런서 순서이나 위의설정을 하면
80 > 로드벨런서 > 443 > 로드벨런서 순서로 바뀐다.
nslookup 를 활용하여 도메인에 정상적으로 연결됬는지 확인할수 있다.
참고자료
certbot 으로 let's encrypt 인증서 발급받기
certbot 을 통해 let's encrypt 인증서를 발급받아보자. 현재로서는 가장 간단한 방법인 것 같다. 공식 사이트 가이드를 따라 진행한다. 아래 페이지를 참고했다. certbot 가이드: https://certbot.eff.org/instruc
bitgadak.tistory.com
https://certbot.eff.org/instructions?ws=nginx&os=ubuntubionic
Certbot Instructions
Tagline
certbot.eff.org
https://jw910911.tistory.com/89
AWS : HTTP에서 HTTPS로 redirection 설정하기 (http_x_forwarded_proto + EC2 +ELB)
redirection 문제 회사에서 데모를 위한 웹서버를 띄우기 위해 AWS 인프라를 구축할 일이 생겼습니다. 기본적으로 AWS의 ELB와 EC2 그리고 Nginx만을 이용한 간단한 웹 서버를 구축하였는데, 이때 HTTPS 인
jw910911.tistory.com