Home CentOS7 certbot 서브도메인 ssl 와일드카드 인증서 설정

certbot 서브도메인 ssl 와일드카드 인증서 설정

by maxblog
0 comment
certbot certonly --manual -d *.domain.com -d domain.com --preferred-challenges dns

certbot로 인증서를 발급받을 때 여러개의 서브도메인 적용하는 경우 일일히 하기 힘드므로
위와 같은 코드를 사용하여 발급해주면 됩니다.

와일드카드 인증서라고도 불리는데 이와 같이 하면 편하게 한방에 사용할 수 있다.

위와 같이 입력을 해주면 DNS 의 TXT 값에 암호코드를 넣으라고 하면서 암호를 출력해주는데
TXT의 Data 항복에 복사해서 붙여주고 인증을 해주면 된다.

이렇게 하면 certbot 인증서 생성하는 것은 끝난다.
이것으로 끝나는 것이 아니라 nginx 설정에서 다음과 같이 맞춰줘야한다.

banner
IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/maxweb.kr-0001/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/maxweb.kr-0001/privkey.pem
   Your certificate will expire on 2023-05-03. To obtain a new or
   tweaked version of this certificate in the future, simply run
   certbot again. To non-interactively renew *all* of your
   certificates, run "certbot renew"
 - If you like Certbot, please consider supporting our work by:

성공 메세지가 나올때 아래 두개 pem 키파일의 경로를 nginx server 부분에 설정을 맞춰줘야한다.
없는 경우 새로 추가해주고 기존에 사용하던 키파일이 있으면 위의 내용으로 정확히 수정해서 맞춰준다.

    listen 443 ssl;
    ssl_certificate /etc/letsencrypt/live/maxweb.kr-0001/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/maxweb.kr-0001/privkey.pem; # managed by Certbot

보통 이와 같이 맞춰준다. maxweb.kr-0001 과 같이 경로 부분이 중요하다.
이렇게 하고 nginx를 재시작하고 ssl 접속이 잘되면 끝이다.
이제 무한대의 ssl 서브도메인을 사용할 수 있다.

이것을 모르면 괜히 dns를 건들고 서브도메인마다 nginx의 server 부분을 만들고 또는
서브 도메인마다 certbot로 ssl키를 추가할때 만들고 말도 안되는 짓을 계속 해야한다.
물론 서너개까지는 괜찮지만…많은 서브도메인을 자동으로 사용하려면
이렇게 와일드카드 서브도메인으로 세팅을 해주는것이 정석이다…^^;

좋아할만한 추천 글

Leave a Comment

Soledad is the Best Newspaper and Magazine WordPress Theme with tons of options and demos ready to import. This theme is perfect for blogs and excellent for online stores, news, magazine or review sites.

Buy Soledad now!

Edtior's Picks

Latest Articles

ⓒ 2023.  FUNCOM all rights reserved.