목표: 발급된 domain을 http:80, https:443 모두 접속이 가능하도록 설정하기
reference link: velog
Free SSL Certificates(in Foreign sites)
1. SSL For Free
2. ZeroSSL
3. Let's Encrypt
위 세가지 중 Let's Encrypt를 사용하기로 결정함
이를 위해 certbot을 설치해야 한다.
https://certbot.eff.org/
# 기존 certbot 제거
sudo apt-get remove certbot
# 2 .Install snapd
# Ubuntu 20.04의 경우 snapd가 미리 설치되어 있다
# https://snapcraft.io/docs/installing-snapd
# 3. Ensure that your version of snapd is up to date
sudo snap install core
# 4. Remove certbot -auto and any Certbot OS packages
# 이 부분은 해당 없으니 pass
# 5. Install Certbot
sudo snap install --classic certbot
# 6. Prepare the Certbot command
sudo ln -s /snap/bin/certbot /usr/bin/certbot
# 7. Choose how you'd like to run Certbot
# 여기서, just get a certificate 명령어를 수행함
sudo certbot certonly --nginx
# 7번에서 nginX가 ubuntu server에 설치되어 있지 않아서 오류가 발생하는 것으로 보인다. nginX 설치 필요함
sudo apt install nginx
# p.s] sudo apt remove nginx # remove command
# nginx 설치 이후 7번 command 다시 실행
email, domain 입력 완료
# 8. Test automatic renewal
sudo certbot renew --dry-run
# etc] To check the certbot certificates by using this command
sudo certbot certificates
# nginx command
sudo service nginx stop
sudo service nginx start
sudo service nginx restart
# check if the configuration file is vaild
sudo nginx -t
/etc/nginx 에서, sites-available > default 파일 수정# [domain-name] 부분은 사용할 domain address를 작성하면 된다
server {
listen 80;
listen [::]:80;
return 301 [domain-name];
}
server {
listen 443 ssl default_server;
ssl on;
ssl_certificate /etc/letsencrypt/live/[domain-name]/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/[domain-name]/privkey.pem;
location / {
# NodeJS Express server를 사용하므로 port number: 3000
proxy_pass http://[domain-name]:3000;
}
}
현재 NodeJS Express server를 사용하고 있으므로, nginX를 사용할 필요가 없다고 판단하여, 기존의 nginX certbot certificates를 지운 뒤, Certbot 공식 사이트에서 Web Hosting Product on Ubuntu 20의 certbot certificates를 새로 발급받기로 결정
live directory exists for [domain-name]--manual option을 사용하지 않고 그냥 설치하니 자동으로 nginX로 연결되는 것 같아서(내 생각), --manual option을 사용해서 설치하기로 함sudo certbot certonly --manual
live directory exists for [domain-name] 라는 빨간 글씨가 콘솔 창에서 출력되었다.