728x90
반응형
SMALL

도메인을 연결하기 위해서는 Certbot을 이용해야하기 때문에 우분투에 설치 먼저해줘야합니다.

  1. Certbot을 설치하고 업데이트하세요.
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot python3-certbot-nginx

2. Certbot을 사용하여 인증서를 생성하세요.

sudo certbot --nginx

Certbot을 실행할 때 도메인 이름을 입력하라는 메시지가 표시됩니다. 여기에 도메인 이름을 입력하고 인증서 생성 프로세스를 완료하세요.

If you really want to skip this, you can run the client with
--register-unsafely-without-email but you will then be unable to receive notice
about impending expiration or revocation of your certificates or problems with
your Certbot installation that will lead to failure to renew.

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.3-September-21-2022.pdf>. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, 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

ubuntu@ip-172-31-46-142:~$ sudo certbot --nginx
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Please enter the domain name(s) you would like on your certificate (comma and/or
space separated) (Enter 'c' to cancel): 도메인이름
Requesting a certificate for 도메인이름

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/도메인이름/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/도메인이름/privkey.pem
This certificate expires on 2023-07-07.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

Deploying certificate
Successfully deployed certificate for 도메인이름 to /etc/nginx/sites-enabled/default
Congratulations! You have successfully enabled HTTPS on 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   <https://letsencrypt.org/donate>
 * Donating to EFF:                    <https://eff.org/donate-le>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

저장된 위치를 메모장에 따로 기록해주세요! 

3. 생성된 인증서와 키의 경로를 확인하고, Nginx 구성 파일의 ssl_certificatessl_certificate_key 지시문에 올바른 경로를 설정하세요.

예를 들면, 다음과 같이 설정할 수 있습니다.

ssl_certificate /etc/letsencrypt/live/hype.r-e.kr/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/hype.r-e.kr/privkey.pem;

4. Nginx 구성을 테스트하고, 문제가 없다면 다시 로드하여 변경 사항을 적용하세요.

sudo nginx -t
sudo systemctl reload nginx

 

5. 도메인이름과 도메인이름:8080을 확인해주세요~

확인 후 포트포워딩!!

sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

확인하면 도메인 이름으로 스프링 부트가 적용이 된 것을 확인할 수 있습니다!

아직 https 로 리다이렉트를 하지 않아서 http 입니다~ 
그 후에는 로드벨런서 블루/ 그린을 적용할 예정입니다! (무중단 배포 화이팅..!!)

728x90
반응형
LIST

'개발 > sw' 카테고리의 다른 글

리눅스  (0) 2023.05.11
우분투 nginx(4) 리다이렉트  (0) 2023.04.15
우분투 nginx (2) 스프링부트 연결하기  (0) 2023.04.09
우분투 nginx (1) 설치 및 포트 변경  (0) 2023.04.09
http → https 리다이렉트 오류  (0) 2023.04.06

+ Recent posts