๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
์„œ๋ฒ„/Linux

[Linux] certbot 404 ์—๋Ÿฌ type: unauthorized ํ•ด๊ฒฐํ•˜๊ธฐ

by yunamom 2022. 4. 19.
728x90
300x250

์—๋Ÿฌํ•ด๊ฒฐ๊ณผ์ •์„ ์Šค์Šค๋กœ ๊ธฐ์–ตํ•˜๊ธฐ์œ„ํ•ด ํฌ์ŠคํŒ…ํ•ฉ๋‹ˆ๋‹ค. 

AWS ์„œ๋ฒ„ํ™˜๊ฒฝ : Ubuntu, Tomcat9, Nginx(ํ†ฐ์บฃ์—ฐ๋™)

 

Tip: ํ„ฐ๋ฏธ๋„ ์ฐฝ 2๊ฐœ ์ผœ๋†“๊ณ  ์‹คํ–‰ํ•ด์•ผํ•จ.

ํ„ฐ๋ฏธ๋„ ์ฐฝ 2๊ฐœ ์—ฌ๋Š”๋ฒ•
certbot

โœจ์ฒซ๋ฒˆ์งธ ํ„ฐ๋ฏธ๋„ (Ubuntu ์„œ๋ฒ„ ์ ‘์†ํ›„)

certbot ์—๋Ÿฌ 404

ubuntu@:~$ sudo certbot --nginx -d yunamom.duckdns.org
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for yunamom.duckdns.org
Waiting for verification...
Challenge failed for domain yunamom.duckdns.org
http-01 challenge for yunamom.duckdns.org
Cleaning up challenges
Some challenges have failed.

IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: yunamom.duckdns.org
   Type:   unauthorized
   Detail: Invalid response from
   http://yunamom.duckdns.org/.well-known/acme-challenge/JySEiBtvqf8RRcKAbkpPaqAitHPHpY0J7H_ADer58P0
   [13.209.236.220]: 404

   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 certbot certonly --manual --email [์ด๋ฉ”์ผ] -d [๋„๋ฉ”์ธ]
ubuntu@:~$ sudo certbot certonly --manual --email hellokin10@gmail.com -d yunamom.duckdns.org
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator manual, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for yunamom.duckdns.org

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NOTE: The IP of this machine will be publicly logged as having requested this
certificate. If you're running certbot in manual mode on a machine that is not
your server, please ensure you're okay with that.

Are you OK with your IP being logged?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Create a file containing just this data:

KPPagWtoBa8rNj8MzIGoRyXwIcEQv0kNcnvtq7blVkA.0Tc284K9HV1X9hq8oXsrv6Xy9c1aiwswFuGgGzK0F2o

And make it available on your web server at this URL:

http://yunamom.duckdns.org/.well-known/acme-challenge/KPPagWtoBa8rNj8MzIGoRyXwIcEQv0kNcnvtq7blVkA

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue

์—ฌ๊ธฐ์„œ ์—”ํ„ฐ๋ฅผ ๋ˆ„๋ฅด๋ฉด ์ง€๊ธˆ ์ƒ์„ฑ๊ฐ’์„ ๋งŒ๋“ค์–ด์ฃผ์ง€์•Š์•˜์œผ๋ฏ€๋กœ ๋‹น์—ฐํžˆ 404์—๋Ÿฌ๊ฐ€ ๋‚˜์˜จ๋‹ค ๊ทธ๋ฆฌ๊ณ  ๊ฐ’์ด ๋˜ ๋ฆฌ์…‹๋˜๋ฏ€๋กœ

์ด ํ„ฐ๋ฏธ๋„์ฐฝ์„ ๊ทธ๋Œ€๋กœ ๋‘๊ณ  ๋‘๋ฒˆ์งธ ํ„ฐ๋ฏธ๋„์—์„œ ์„œ๋ฒ„์ ‘์†์„ ํ•ด์ค€๋‹ค. (๋„๋ฉ”์ธ ์†Œ์œ ๊ถŒํ™•์ธ์„ ์œ„ํ•œ ์ž‘์—…)

 

์œ„์˜ ๋‚ด์šฉ์€ .well-known/acme-challenge/[์ž„์˜์ƒ์„ฑ๊ฐ’] ์„ ํ˜ธ์ถœํ•  ๋•Œ ์•„๋ž˜์˜ ๊ฐ’์ด ๋ฆฌํ„ด๋˜์–ด์•ผ ํ•œ๋‹ค

*์•„๋ž˜์˜ ๊ฐ’์€ ๊ฐœ๊ฐœ์ธ๋งˆ๋‹ค ๋‹ค๋ฆ…๋‹ˆ๋‹ค ๋ณธ์ธ์˜ ์ž„์˜์ƒ์„ฑ๊ฐ’์„ ํ™•์ธํ•ด์•ผํ•จ

KPPagWtoBa8rNj8MzIGoRyXwIcEQv0kNcnvtq7blVkA.0Tc284K9HV1X9hq8oXsrv6Xy9c1aiwswFuGgGzK0F2o

 

โœจ๋‘๋ฒˆ์งธ ํ„ฐ๋ฏธ๋„ (Ubuntu ์„œ๋ฒ„ ์ ‘์†ํ›„)

ํ†ฐ์บฃ ๋ฃจํŠธ์— ํด๋”/ํŒŒ์ผ ์„ ๋งŒ๋“ค์–ด์ค€๋‹ค.

ubuntu@:/var/lib/tomcat9/webapps/ROOT$ sudo mkdir -p .well-known/acme-challenge
ubuntu@:/var/lib/tomcat9/webapps/ROOT$ ls
META-INF  hi.html  index.html  index.jsp  sudo

# ์ˆจ๊ฒจ์ง„ํด๋”๋ผ ๋ชฉ๋ก์— ๋‚˜์˜ค์ง€์•Š๋Š”๋‹ค ls -a ๋ช…๋ น์–ด๋กœ ํ™•์ธํ• ์ˆ˜์žˆ๋‹ค.

ubuntu@:/var/lib/tomcat9/webapps/ROOT$ ls -a
.  ..  .well-known  META-INF  hi.html  index.html  index.jsp  sudo
 
ubuntu@:/var/lib/tomcat9/webapps/ROOT$ cd .well-known/acme-challenge
ubuntu@:/var/lib/tomcat9/webapps/ROOT/.well-known/acme-challenge$ sudo vi KPPagWtoBa8rNj8MzIGoRyXwIcEQv0kNcnvtq7blVkA
ubuntu@:/var/lib/tomcat9/webapps/ROOT/.well-known/acme-challenge$

ํŒŒ์ผ ์•ˆ์— ๋‹ค์Œ์„ ์ž…๋ ฅ

*์•„๋ž˜์˜ ๊ฐ’์€ ๊ฐœ๊ฐœ์ธ๋งˆ๋‹ค ๋‹ค๋ฆ…๋‹ˆ๋‹ค ๋ณธ์ธ์˜ ์ž„์˜์ƒ์„ฑ๊ฐ’์„ ํ™•์ธํ•ด์•ผํ•จ

KPPagWtoBa8rNj8MzIGoRyXwIcEQv0kNcnvtq7blVkA.0Tc284K9HV1X9hq8oXsrv6Xy9c1aiwswFuGgGzK0F2o

์ ‘์†ํ•ด์„œ ์ถœ๋ ฅํ™•์ธํ›„

http://yunamom.duckdns.org/.well-known/acme-challenge/KPPagWtoBa8rNj8MzIGoRyXwIcEQv0kNcnvtq7blVkA

 

 

โœจ๊ทธ๋‹ค์Œ ์ฒซ๋ฒˆ์งธ ํ„ฐ๋ฏธ๋„ ํ™”๋ฉด์œผ๋กœ ๋Œ์•„๊ฐ€์„œ ์—”ํ„ฐ๋ฅผ ๋ˆŒ๋Ÿฌ์ค€๋‹ค.

Press Enter to Continue
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/yunamom.duckdns.org/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/yunamom.duckdns.org/privkey.pem
   Your cert will expire on 2022-07-18. 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:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

ubuntu@:~$

๊ทธํ›„์— ์•„๋ž˜ ๋ช…๋ น์–ด๋กœ SSL ์ธ์ฆ์„œ ๋ฐœ๊ธ‰ ( http -> https )

ubuntu@:~$ sudo certbot --nginx -d yunamom.duckdns.org
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Cert not yet due for renewal

You have an existing certificate that has exactly the same domains or certificate name you requested and isn't close to expiry.
(ref: /etc/letsencrypt/renewal/yunamom.duckdns.org.conf)

What would you like to do?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Attempt to reinstall this existing certificate
2: Renew & replace the cert (limit ~5 per 7 days)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1
Keeping the existing certificate
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/tomcat.conf

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/tomcat.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://yunamom.duckdns.org

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/yunamom.duckdns.org/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/yunamom.duckdns.org/privkey.pem
   Your cert will expire on 2022-07-18. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - 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

ubuntu@:~$

์™„๋ฃŒ!

 

728x90
300x250

์ฝ”๋“œ