nginx로 ssl 인증서 등록하기

이소진·2021년 10월 28일
0

0.homebrew 설치

설치 되어있다면 1번으로 pass!

sudo apt install linuxbrew-wrapper

1. certbot 설치

brew install certbot

2. certbot package 설치

sudo apt install certbot python3-certbot-nginx

3. ssh연결 허용

sudo ufw allow ssh / sudo ufw allow 'Nginx Full'

4. 인증서 발급

sudo certbot --nginx

Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): 메일 입력
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: https 적용시키고 싶은 도메인 주소 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for admin.flumeride.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/default

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): 2
Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/default

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://admin.flumeride.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=admin.flumeride.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Congratulations!가 보인다면 인증서 등록이 완료된 것!

/etc/nginx/sites-avilable에 있는 default 파일은 따로 건들이지 않아도 됩니다.
certbot이 알아서 해주기 때문이죠...

5. nginx 재부팅

sudo systemctl restart nginx

6. 443 포트 열기

80번 포트로 연결되면 443포트로 리다이렉트 되게끔 certbot이 설정해주었기 때문에 443포트를 꼭 열어두어야 합니다! ⭐️⭐️⭐️⭐️제발 열어주세요 여러분
저 같은 경우는 443포트를 열어두지 않고 삽질만 했다는 .....

참고
https://jjeongil.tistory.com/1281 (ufw방화벽 관련)

profile
webFront / Flutter / iOS 😉

0개의 댓글