[MAC] ๋ฌด๋ฃŒ ๋„๋ฉ”์ธ ๋ฐœ๊ธ‰ ๋ฐ SSL ์ธ์ฆ์„œ ์ ์šฉํ•˜๊ธฐ , Node.js + express ํŒจํ‚ค์ง€
๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๋””์ง€ํ„ธ ๊ฟ€ํŒ

[MAC] ๋ฌด๋ฃŒ ๋„๋ฉ”์ธ ๋ฐœ๊ธ‰ ๋ฐ SSL ์ธ์ฆ์„œ ์ ์šฉํ•˜๊ธฐ , Node.js + express ํŒจํ‚ค์ง€

by ์ผ์ƒ์„ ๊ณต์œ ํ•ฉ๋‹ˆ๋‹ค 2022. 8. 20.

๋„๋ฉ”์ธ์ด ์—†๋‹ค๋ฉด ๋จผ์ € ๋ฌด๋ฃŒ ๋„๋ฉ”์ธ์„ ๋ฐœ๊ธ‰๋ฐ›์Šต๋‹ˆ๋‹ค. ๋ฌด๋ฃŒ ๋„๋ฉ”์ธ ๋ฐœ๊ธ‰ ์‚ฌ์ดํŠธ๋Š” ์•„๋ž˜ ๋งํฌ๋ฅผ ์ฐธ์กฐ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

 

๋ฌด๋ฃŒ ๋„๋ฉ”์ธ ์‚ฌ์ดํŠธ ์•ˆ๋‚ด, ๋‚ด๋„๋ฉ”์ธ.ํ•œ๊ตญ , freenom

SSL ์ธ์ฆ์ด ์•ˆ๋˜์„œ iptime ๋„๋ฉ”์ธ ๋Œ€์‹ ํ•  ๋ฌด๋ฃŒ ๋„๋ฉ”์ธ ์ œ๊ณต ์‚ฌ์ดํŠธ๋ฅผ ์•Œ๊ฒŒ๋˜์–ด ๊ณต์œ ํ•ด๋ด…๋‹ˆ๋‹ค. 1. ๋‚ด.๋„๋ฉ”์ธ.ํ•œ๊ตญ https://xn--220b31d95hq8o.xn--3e0b707e/ ๋‚ด๋„๋ฉ”์ธ.ํ•œ๊ตญ - ํ•œ๊ธ€ ๋ฌด๋ฃŒ ๋„๋ฉ”์ธ ๋“ฑ๋ก์„ผํ„ฐ ํ•œ๊ธ€ ๋ฌด

odaily.tistory.com

 

Let's Encrypt์—์„œ SSL ์ธ์ฆ์„œ ๋ฐœ๊ธ‰ ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.

1.  ๋ช…๋ น์–ด ์ž…๋ ฅ

ํ„ฐ๋ฏธ๋„์„ ์—ด์–ด ์•„๋ž˜์™€ ๊ฐ™์ด ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

sudo certbot certonly --manual

 

2.  E-mail ์ฃผ์†Œ ๋ฐ ๋„๋ฉ”์ธ ์ž…๋ ฅ ํ›„  ์›น ์†Œ์Šค ๋ฐ˜์˜ ๋ฐ key ํŒŒ์ผ ์ €์žฅ

ํ•œ๋ฒˆ ์ด๋ฉ”์ผ ๋“ฑ๋กํ•˜๊ณ  ๋„๋ฉ”์ธ ์ž…๋ ฅ ํ›„ ์ธ์ฆ ๊ณผ์ •์—์„œ ์˜ค๋ฅ˜ ๋‚˜๋ฉด ๊ทธ๋‹ค์Œ ๋ฒˆ ์ง„ํ–‰์—” ๋ฐ”๋กœ ๋„๋ฉ”์ธ ์ž…๋ ฅํ•˜๋ผ๊ณ  ๋œน๋‹ˆ๋‹ค. ๋„๋ฉ”์ธ ์ž…๋ ฅํ•˜๋ฉด ํ„ฐ๋ฏธ๋„์— ์•„๋ž˜์™€ ๊ฐ™์ด ๋ฉ”์‹œ์ง€๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

์œ„ ๋ฉ”์‹œ์ง€ ๋ง๋Œ€๋กœ ํŒŒ์ผ ์•ˆ์— ํ‚ค ๋ฐ์ดํ„ฐ๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค. ์ถ”๊ฐ€์ ์œผ๋กœ ์œ„ URL๋กœ ๋ฐ์ดํ„ฐ๊ฐ€ ์ถœ๋ ฅ๋˜๋„๋ก ์›น์†Œ์Šค๋ฅผ ์ˆ˜์ •ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

app.get('/.well-known/acme-challenge/ํŒŒ์ผ์ฃผ์†Œ๋ช…', function(req,res) {
    fs.readFile(__dirname + "/.well-known/acme-challenge/ํŒŒ์ผ์ฃผ์†Œ๋ช…", 'utf8'  , (err, data) => {
        if (err) {
          console.error(err)
          return
        }
        res.send(data);
      })
})

์ˆ˜์ • ํ›„ ์›น์„ ๋‹ค์‹œ ๊ตฌ๋™ํ•ฉ๋‹ˆ๋‹ค. ์ฆ‰ http://๋„๋ฉ”์ธ~~ / ํ˜ธ์ถœํ•˜๋ฉด ์œ„ ๋ฐ์ดํ„ฐ๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์ถœ๋ ฅ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

๊ทธ๋Ÿผ ๋‹ค์‹œ ํ„ฐ๋ฏธ๋„๋กœ ๋Œ์•„์™€ enter๋ฅผ ์ž…๋ ฅํ•˜์—ฌ ์ •์ƒ์ ์ธ ๋ฐœ๊ธ‰์„ ํ™•์ธํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
์ฐธ๊ณ ๋กœ ์ €๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ์˜ค๋ฅ˜๊ฐ€ 2๋ฒˆ์ด๋‚˜ ๋ฐœ์ƒํ•˜์—ฌ ์ˆ˜์ •ํ•œ ํ›„ ์ •์ƒ ๋ฐœ๊ธ‰ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

 

iptime ๋„๋ฉ”์ธ https ์„ค์ •ํ•˜๊ธฐ ์˜ค๋ฅ˜ : ddns์— caa ์ธ์ฆ ๋ถˆ๊ฐ€

Let's Encrypt CAA ์˜ค๋ฅ˜ ์˜ˆ์‹œ CAA record for ๋„๋ฉ”์ธ prevents issuance 2020๋…„ 7์›” ์ดํ›„์—๋Š” iptime ddns ์ด์šฉํ•˜๋Š” ์ฃผ์†Œ๋Š” https ์ธ์ฆ์ด ๋ถˆ๊ฐ€ํ•˜๋‹ค๊ณ  ํ•œ๋‹ค. ์ด๋Š” ์–ด๋– ํ•œ ์ธ์ฆ์„œ๋„ CAA ์ธ์ฆ์„ ๋ถˆํ—ˆํ•˜๋ฏ€๋กœ ์˜ค๋ž˜๋œ..

odaily.tistory.com

 

SSL ์ธ์ฆ์„œ ๋ฐœ๊ธ‰ ์—๋Ÿฌ, An unexpected error occurred: Error creating new order :: too many certificates already issued for

์ธ์ฆ์„œ ๋ฐœ๊ธ‰ ์—๋Ÿฌ ํŠน์ • ์œ ํ˜•์˜ ์š”์ฒญ์„ ๋„ˆ๋ฌด ๋งŽ์ด ํ•œ ๊ฒฝ์šฐ ์•„๋ž˜์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค. Let’s Encrypt SSL ์ธ์ฆ์„œ๋Š” 5ํšŒ ๋ฐœ๊ธ‰์œผ๋กœ ์ œํ•œ๋˜์–ด ์žˆ๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. An unexpected error occurred: Error creating new..

odaily.tistory.com

 

3.  ์ •์ƒ์ ์ธ. pem ์ธ์ฆ ๊ด€๋ จ ํŒŒ์ผ ์ƒ์„ฑ, ์œ ํšจ๊ธฐ๊ฐ„ ํ™•์ธ(3๊ฐœ์›”)

๋ฐœ๊ธ‰ ์ง„ํ–‰์ด ์ž˜ ๋˜๋ฉด ์•„๋ž˜ ๊ฒฝ๋กœ์—. pem ํŒŒ์ผ์ด ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.

fullchain.pem
privkey.pem

 

4. ์›น ์†Œ์Šค์— ๋ฐ˜์˜ ๋ฐ 443 port ์—ด๊ธฐ

๋ฐ”๋กœ ์›น์†Œ์Šค์—์„œ https ๊ด€๋ จ ์†Œ์Šค ์ ์šฉํ•ฉ๋‹ˆ๋‹ค.

var ca = fs.readFileSync('/etc/letsencrypt/live/odaily.kro.kr/fullchain.pem')
var privateKey = fs.readFileSync('/etc/letsencrypt/live/odaily.kro.kr/privkey.pem')
var certificate = fs.readFileSync('/etc/letsencrypt/live/odaily.kro.kr/cert.pem')

const credentials = { key: privateKey, cert: certificate, ca: ca }

var app = express()

app.use(express.static('public'));


http.createServer(app).listen(80)
https.createServer(credentials, app).listen(443)

 

์›น ์„œ๋ฒ„ ์žฌ๊ตฌ๋™์‹œ ์ •์ƒ์ ์œผ๋กœ https๊ฐ€ ๋™์ž‘ํ•˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์›น ์„œ๋ฒ„๋ถ€ํ„ฐ ๋„์šฐ๋Š” ๊ฑธ ์•Œ๊ณ  ์‹ถ๋‹ค๋ฉด ์•„๋ž˜ ๋งํฌ๋ถ€ํ„ฐ ํ™•์ธํ•ด๋ณด์„ธ์š”

 

Node JS ,express ํŒจํ‚ค์ง€๋กœ ์›น์„œ๋ฒ„ ๊ตฌ๋™ํ•˜๊ธฐ

NodeJs ๊ธฐ์ดˆ ์•Œ์•„๊ฐ€๊ธฐ ์ž๋™ํ™”๋ฅผ ์œ„ํ•ด์„œ๋Š” Selenium ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋กœ node ,python์„ ์‚ฌ์šฉํ•˜์—ฌ ์›น์„ ์ปจํŠธ๋กค ํ•ฉ๋‹ˆ๋‹ค. ํฌ๋กฌ๋„ ๊ตฌ๊ธ€์—์„œ ๋งŒ๋“  ์–ธ์–ด์ด๊ธฐ ๋•Œ๋ฌธ์— GAS (Google App Script) ๋กœ Chrome์„ ์ œ์–ดํ•  ์ˆ˜ ์—†๋‚˜ ์ƒ๊ฐ

odaily.tistory.com

 

๋Œ“๊ธ€