๐Ÿ“

5. AWS

1. ๊ฐ€๊ฒฉ ๋ฐ ์„ฑ๋Šฅ ๋น„๊ต

2. ํšŒ์›๊ฐ€์ž…

๐Ÿ“
ํšŒ์› ๊ฐ€์ž…

3. Lightsail

์„ ํƒ ์ด์œ  : ๊ฐ€๊ฒฉ ์ €๋ ดํ•˜์—ฌ ์˜ค๋žซ๋™์•ˆ ์—ฌ๋Ÿฌ๋ถ„ ํ”„๋กœ์ ํŠธ๋ฅผ ์œ ์ง€ํ•˜๊ธฐ ์ข‹์Šต๋‹ˆ๋‹ค.
  • ๋กœ๊ทธ์ธ์šฉ URL : https://scloudy.signin.aws.amazon.com/console
    • ๊ณ„์ • ID๋ฅผ ๋ชจ๋ฅผ ๊ฒฝ์šฐ ๋ฃจํŠธ ์‚ฌ์šฉ์ž ์ด๋ฉ”์ผ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋กœ๊ทธ์ธ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜์—ฌ ๋กœ๊ทธ์ธ ํ•ด์ฃผ์„ธ์š”.
      notion imagenotion image
  • ๊ด€๋ฆฌ ์ฝ˜์†”
    • notion imagenotion image
      notion imagenotion image
  • ์ „์ฒด ์ œํ’ˆ๊ตฐ์—์„œ ๊ฐ€์žฅ ๋งŽ์ด ์‚ฌ์šฉ๋˜๋Š” ๊ฒƒ์€ EC2, Lightsail, S3(์ด๋ฏธ์ง€ ์ €์žฅ๊ณผ ๊ฐ™์€ ์ €์žฅ์„œ๋น„์Šค)
    • notion imagenotion image
  • ๋กœ๊ทธ์ธํ•œ ์ฝ˜์†”์—์„œ ๊ฒ€์ƒ‰ํ•ด๋ณด์•„๋„ ๋ฉ๋‹ˆ๋‹ค.
    • notion imagenotion image
  • ํšŒ์‚ฌ์—์„œ๋Š” ๋ณดํ†ต AWS๋ฅผ ์‚ฌ์šฉํ•˜์ง€๋งŒ AWS๊ฐ€ ์™ธ๊ตญํšŒ์‚ฌ๋‹ค ๋ณด๋‹ˆ ํšŒ์‚ฌ์—์„œ ๋ฒ•์ ์ธ ์š”๊ฑด์ด ์ถฉ์กฑ๋˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋งŽ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฐ ์ด์œ ๋•Œ๋ฌธ์— Naver์—์„œ ์ œ๊ณตํ•˜๋Š” ํด๋ผ์šฐ๋“œ ์„œ๋น„์Šค์ธ NCP๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค. (NCP ์‚ฌ์šฉ๋ฒ•์€ ์•„๋ž˜ ์˜์ƒ ์ฐธ๊ณ ) ์‚ฌ์šฉ๋ฒ•์€ ์–ด๋–ค ํด๋ผ์šฐ๋“œ ์„œ๋น„์Šค๋ฅผ ์‚ฌ์šฉํ•˜์‹œ๋“ ์ง€ ๋Œ€๋ถ€๋ถ„ ์œ ์‚ฌํ•ฉ๋‹ˆ๋‹ค.
      1. ํด๋ผ์šฐ๋“œ ์„œ๋ฒ„๋ฅผ ํ• ๋‹น๋ฐ›๋Š”๋‹ค.
      1. ์„œ๋น„์Šค์™€ ๊ด€๋ จ์žˆ๋Š” ์„œ๋ฒ„๋“ค์„ ์—ฐ๊ฒฐํ•œ๋‹ค.
      1. ์›๊ฒฉ ์ ‘์†ํ•˜์—ฌ ์ฝ”๋“œ๋ฅผ ๋ฐฐํฌํ•œ๋‹ค.
      Video preview
ย 
  • ์ฝ˜์†”์—์„œ โ€œLightsailโ€ ๊ฒ€์ƒ‰ ํ›„ ํด๋ฆญ, letโ€™s get started ๋ˆŒ๋Ÿฌ์ฃผ์„ธ์š”.
    • notion imagenotion image
      notion imagenotion image
notion imagenotion image
ย 
  • ๋งŒ์•ฝ ์šด์˜ํ•˜๊ณ  ์žˆ๋Š” ์„œ๋น„์Šค๊ฐ€ ์žˆ๋‹ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ๋–ด์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ์„ ๋ˆŒ๋Ÿฌ์ฃผ์„ธ์š”. ์œ„์™€ ๋™์ผํ•œ ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.
    • notion imagenotion image
      ย 
  • ์ ‘์† ๋ฐฉ๋ฒ•์€ ์›น ์ ‘๊ทผ๊ณผ ์›๊ฒฉ ์ ‘์†์ด ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ(์šฐ๋ถ„ํˆฌ๋กœ ์ƒ์„ฑํ•ด ์ฃผ์„ธ์š”.)
    • notion imagenotion image
  • ์„ค์ •๊ณผ ๊ฐ€๊ฒฉ(ํ”Œ๋žœ ์„ ํƒ)
    • notion imagenotion image
      notion imagenotion image
ย 
  • Cafe24์™€ ๋น„๊ต
    • notion imagenotion image
ย 
  • ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ ํ™•์ธ (IP๋กœ ์ ‘์†ํ•˜๋ฉด ๋Œ์•„๊ฐ€๊ณ  ์žˆ๋Š” ์„œ๋น„์Šค๋ฅผ ํ™•์ธํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.)
    • notion imagenotion image
      notion imagenotion image
      notion imagenotion image
ย 
  • ์ž ์‹œ ๊ธฐ๋‹ค๋ฆฌ๋ฉด ํ™œ์„ฑํ™”๋˜๋ฉฐ, ์›น์—์„œ ์ฝ˜์†”๋กœ ์ ‘์†ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    • notion imagenotion image
ย 
  • ์›น์œผ๋กœ ์ ‘์†ํ•˜๋Š” ๊ฒƒ์ด ํŽธํ•ฉ๋‹ˆ๋‹ค. ์ปดํ“จํ„ฐ์— key๋ฅผ ๋‹ค์šด๋ฐ›๊ณ  ssh๋กœ ์ ‘์†ํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ์žˆ์Šต๋‹ˆ๋‹ค.
    • notion imagenotion image
ย 
ย 
  • ๊ตฌ๋ฆ„IDE๋ฅผ ์‚ฌ์šฉํ•ด๋ณด์‹  ์ ์ด ์žˆ์œผ์‹œ๋‹ค๋ฉด ๊ตฌ๋ฆ„IDE์˜ ssh ์ ‘์† ๋ช…๋ น์–ด๋„ ํ•œ ๋ฒˆ ํ™•์ธํ•ด๋ณด์„ธ์š”. (๊ตฌ๋ฆ„IDE๋„ AWS๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.)
    • ssh -p 53435 root@15.165.76.108
      notion imagenotion image
ย 
  • SSHํ‚ค ๋‹ค์šด๋กœ๋“œ
    • notion imagenotion image
      notion imagenotion image
      notion imagenotion image
      notion imagenotion image
      notion imagenotion image
  • ์ ‘์† ๋ช…๋ น์–ด
    • ssh ubuntu@๋‚ด์„œ๋ฒ„IP -i ./LightsailDefaultKey-ap-northeast-2.pem
      notion imagenotion image
  • ๋ฆฌ๋ˆ…์Šค ๋ช…๋ น์–ด(Shift + Insert ํ‚ค๋ฅผ ๋ˆ„๋ฅด๋ฉด ๋ถ™์—ฌ๋„ฃ๊ธฐ๊ฐ€ ๋ฉ๋‹ˆ๋‹ค.)
    • chmod 400 ~/.ssh/LightsailDefaultKey-ap-northeast-2.cer ssh ubuntu@๋‚ด์„œ๋ฒ„IP -i ~/.ssh/LiglshtsailDefaultKey-ap-northeast-2.cer sudo apt-get update sudo apt-get install nginx -y # nginx ์‹œ์ž‘ํ•˜๋Š” ๋ช…๋ น # sudo systemctl start nginx cd /var/www/html/
      notion imagenotion image
  • ํŒŒ์ผ ์ˆ˜์ •ํ•˜๊ณ  ์—ฌ๋Ÿฌ๋ถ„์˜ IP๋กœ ์ ‘์†ํ•ด๋ณด์„ธ์š”. ์ด๋ฏธ ์ ‘์†ํ•ด ์žˆ๋Š” ๊ฒฝ์šฐ ์ƒˆ๋กœ๊ณ ์นจํ•˜์‹ญ์‹œ์˜ค.
    • notion imagenotion image
  • route53 ๊ฒ€์ƒ‰ ํ›„ ๋„๋ฉ”์ธ ์—ฐ๊ฒฐ (์ƒํ™œ์ฝ”๋”ฉ ๊ฐ•์˜ ์ถ”์ฒœํ•ด๋“œ๋ฆฝ๋‹ˆ๋‹ค. ํ•ด๋‹น ๊ฐ•์˜๋Š” AWS ํ›„์›์œผ๋กœ ๋งŒ๋“ค์–ด์ง„ ๊ฐ•์˜์—์š”.)
    • notion imagenotion image
      notion imagenotion image
  • ๋„๋ฉ”์ธ ๋“ฑ๋ก
    • notion imagenotion image
  • DNS ๊ด€๋ฆฌ
    • notion imagenotion image
  • ํ˜ธ์ŠคํŒ… ์˜์—ญ ์ƒ์„ฑ(๋ ˆ์ฝ”๋“œ ์ด๋ฆ„๊ณผ ๊ฐ’ ์ž…๋ ฅ)
    • notion imagenotion image
      notion imagenotion image
ย 

๋ถ€๋ก

  • Networking์—์„œ Loadbalancer๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ํ•˜๋‚˜์˜ ์„œ๋ฒ„๊ฐ€ ๋‹ค์šด๋˜์—ˆ์„ ๋•Œ ๋‹ค๋ฅธ ๋Œ€์ฒด ์„œ๋ฒ„๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๊ฒƒ์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์œ„์— ์„œ๋ฒ„๋ฅผ ์—ฌ๋Ÿฌ๊ฐœ ์ƒ์„ฑํ•ด๋‘์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
    • notion imagenotion image
      notion imagenotion image
ย 
  • ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ๋ณ„๋„๋กœ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋Œ€์‹  DB๋Š” ๊ฐ€๊ฒฉ์ด ์กฐ๊ธˆ ๋‚˜๊ฐ‘๋‹ˆ๋‹ค.
    • notion imagenotion image
      notion imagenotion image
      notion imagenotion image
  • ์Šค๋ƒ…์ƒท ์„ค์ •๋„ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ๋งค์ผ ๋ฐค ๋ฐฑ์—…์„ ํ•ด์ฃผ๋Š” ๊ธฐ๋Šฅ์ด์—์š”.
    • notion imagenotion image
ย 

node ๋ฐฐํฌ์‹œ

์ฒ˜์Œ Node ์ปจํ…Œ์ด๋„ˆ๋กœ ์ƒ์„ฑ ํ›„ ์•„๋ž˜ ์ฝ”๋“œ ์ž…๋ ฅ
cd htdocs rm -rf * git clone ์ฃผ์†Œ . npm i node app // ์ฝ˜์†”์ด ๋‹ซํ˜€๋„ ๊ณ„์† ์‹คํ–‰ํ•˜๋Š” ๋ช…๋ น์–ด๋Š” nohup node app &, ๋‚˜์ค‘์— kill ํ•˜์…”์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” ์›น ํ„ฐ๋ฏธ๋„์ด ์•„๋‹Œ ํ„ฐ๋ฏธ๋„์—์„œ ์‹คํ–‰ํ•˜์…”์•ผ ํ•ฉ๋‹ˆ๋‹ค.(https://morningame.tistory.com/154 ๊ธ€์„ ์ฐธ๊ณ ํ•ด๋ณด์„ธ์š”. ์™„์ „ํžˆ ์ฃฝ์ง€ ์•Š๊ฒŒ ํ•˜๋ ค๋ฉด forever๋ฅผ ์‚ฌ์šฉํ•˜์…”์•ผ ํ•ฉ๋‹ˆ๋‹ค.)
  • node ๋ฐฐํฌ์‹œ static IP ์ƒ์„ฑ ํ•„์š”.
    • notion imagenotion image
ย 
  • ์„œ๋ฒ„ ์„ ํƒ ํ›„ Create
    • notion imagenotion image
  • ์ƒ์„ฑ๋œ ์•„์ดํ”ผ ๊ธฐ๋ก
    • notion imagenotion image
  • Node ํด๋ฆญ ํ›„ Networking ํƒญ์œผ๋กœ ์ด๋™
    • notion imagenotion image
  • ์•„๋ž˜ add rule์„ ํ†ตํ•ด 8080ํฌํŠธ Create
    • notion imagenotion image
  • ์ƒ์„ฑ ํ™•์ธ
    • notion imagenotion image
  • ๊ณ ์ •์•„์ดํ”ผ:8080์œผ๋กœ ์ ‘์†
    • notion imagenotion image
ย 
  • node ๋ฐฐํฌ์‹œ CSP ์ •์ฑ…์— ๋”ฐ๋ผ ๋ฐฐํฌ๊ฐ€ ์ œ๋Œ€๋กœ ์•ˆ๋˜๋Š”(CSS๊ฐ€ ์ œ๋Œ€๋กœ ๋ณด์ด์ง€ ์•Š๋Š”) ํ˜„์ƒ์ด ์žˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ”„๋กœ์ ํŠธ๋งˆ๋‹ค ์•„๋ž˜ ๊ธ€์— ๋”ฐ๋ผ ์กฐ์น˜ํ•ด์ฃผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.
  • ์œ„ ์กฐ์น˜๋กœ๋„ ์•ˆ๋˜๋Š” ๊ฒฝ์šฐ๋Š” ์•„๋ž˜ ์‚ฌํ•ญ์„ ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”.
    • app.use(helmet()) ์ฝ”๋“œ ์‚ญ์ œ(์•„๋ž˜ ์ฝ”๋“œ๋ฅผ ๋ชจ๋‘ ์ž…๋ ฅํ•œ ๊ฒƒ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.)
      • notion imagenotion image
    • ์•„๋ž˜ ์ฝ”๋“œ ์ถ”๊ฐ€
      • app.use(helmet({ contentSecurityPolicy:false, }));

4. AWS S3

๐Ÿ“
๋ถ€๋ก : AWS s3์—์„œ ์ •์ ํŽ˜์ด์ง€ ํ˜ธ์ŠคํŒ…ํ•˜๊ธฐ
ย 
ย