AWS

Nginx에 https 적용하기

잔망루피 2023. 12. 4. 23:57
반응형

certbot을 이용해서 배포한 서버에 https를 적용할 것이다.

나는 Nginx를 Proxy server 용도로 사용하고 있다.

공식 문서를 참고했는데 너무 간단하게 https를 적용할 수 있었다. (공식 문서 최고 🤗)

 

 

 

1. 사전 준비

https://certbot.eff.org/instructions

Software, System을 선택하면 그에 따른 설명을 보여준다.

나는 Ubuntu 22 LTS를 사용하는데 저 선택 옵션에서는 Ubuntu 20까지밖에 없지만, 상관없다.

 

 

sudo apt-get remove certbot
sudo dnf remove certbot
sudo yum remove certbot

 

apt / dnf / yum을 이용해서 Certbot을 설치했었다면, Certbot snap을 설치하기 전에 삭제해준다.

 

sudo snap install --classic certbot

Certbot을 설치한다.

 

sudo apt-get install python3-certbot-nginx

위 명령어를 실행하지 않으면, The requested nginx plugin does not appear to be installed 에러가 뜬다.

 

sudo ln -s /snap/bin/certbot /usr/bin/certbot

certbot 명렁어가 실행될 수 있도록 한다.

ln: failed to create symbolic link '/usr/bin/certbot': File exists 이런 에러가 뜨면, sudo rm /usr/bin/certbot을 해서 삭제하고 다시 시도하면 된다.

 

2. https 적용하기

나는 증명서도 발급받고, nginx 설정도 자동으로 변경하도록 했다.

sudo certbot --nginx

 

이메일을 입력하고 약관에 동의한다.

첫 번째 약관은 필수고, 두 번째 약관은 선택사항이다.

 

 

나는 도메인에 하나라서 1을 선택해서 https를 적용했다.

/etc/nginx/sites-enabled/default에서 https 설정을 작성하지 않아도 알아서 해준다 !!!

이제 https://구입한 도메인명으로 접속하면 https가 잘 적용된 것을 볼 수 있다.

 

 

👀 에러 모음

🐛 인증서 발급 횟수 초과 에러

Error creating new order :: too many certificates already issued

인증서를 너무 많이 발급받았으면 제한한다.

로그에 인증서 발급 가능 날짜가 나온다.

 

 

🐛 잘못된 레코드 등록 문제

  • check that a DNS record exists for this domain이 뜨면 레코드를 잘못 등록한 것이다.

 

호스트를 www를 추가했다.

certbot으로 SSL 인증서 발급받을 때 호스트는 포함하지 않고 작성하면 된다.

 

 

🐛 80 포트가 막혀있던 문제

To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A/AAAA record(s) for that domain
   contain(s) the right IP address.
sudo ufw allow 80
sudo ufw reload

80 포트를 방화벽을 허용한다.

 

 

 

 


참고 👇👇👇

 

https://certbot.eff.org/instructions?ws=nginx&os=ubuntufocal

 

Certbot Instructions

Tagline

certbot.eff.org

 

https://ywtechit.tistory.com/449

 

[ 도커(Docker) ] Let's Encrypt: Error creating new order :: too many certificates 오류

📍 Let's Encrypt: Error creating new order :: too many certificates 오류 Docker-compose를 이용하여 서버를 배포할 때 SSL(Secure Sockets Layer)인증을 받기 위해 범용적으로 사용하는 무료 인증기관인 Let's Encrypt을 이용

ywtechit.tistory.com

 

https://community.letsencrypt.org/t/to-fix-these-errors-please-make-sure-that-your-domain-name-was-entered-correctly-and-the-dns-a-aaaa-record-s-for-that-domain-contain-s-the-right-ip-address/113178/2

 

To fix these errors, please make sure that your domain name was entered correctly and the DNS A/AAAA record(s) for that domain c

Hi @alfian read your output. A working port 80 is required if you want to create a new certificate. Same picture checking via https://check-your-website.server-daten.de/?q=meeting.bbn.co.id Domainname Http-Status redirect Sec. G • http://meeting.bbn.co.i

community.letsencrypt.org

 

반응형