1. ๊ฐ๊ฒฉ ๋ฐ ์ฑ๋ฅ ๋น๊ต
2. ํ์๊ฐ์
ํ์ ๊ฐ์3. Lightsail
์ ํ ์ด์ : ๊ฐ๊ฒฉ ์ ๋ ดํ์ฌ ์ค๋ซ๋์ ์ฌ๋ฌ๋ถ ํ๋ก์ ํธ๋ฅผ ์ ์งํ๊ธฐ ์ข์ต๋๋ค.
- ๋ก๊ทธ์ธ์ฉ URL : https://scloudy.signin.aws.amazon.com/console
๊ณ์ ID๋ฅผ ๋ชจ๋ฅผ ๊ฒฝ์ฐ
๋ฃจํธ ์ฌ์ฉ์ ์ด๋ฉ์ผ์ ์ฌ์ฉํ์ฌ ๋ก๊ทธ์ธ
๋ฒํผ์ ํด๋ฆญํ์ฌ ๋ก๊ทธ์ธ ํด์ฃผ์ธ์.- ๊ด๋ฆฌ ์ฝ์
- ์ ์ฒด ์ ํ๊ตฐ์์ ๊ฐ์ฅ ๋ง์ด ์ฌ์ฉ๋๋ ๊ฒ์ EC2, Lightsail, S3(์ด๋ฏธ์ง ์ ์ฅ๊ณผ ๊ฐ์ ์ ์ฅ์๋น์ค)
- ๋ก๊ทธ์ธํ ์ฝ์์์ ๊ฒ์ํด๋ณด์๋ ๋ฉ๋๋ค.
- ํ์ฌ์์๋ ๋ณดํต AWS๋ฅผ ์ฌ์ฉํ์ง๋ง AWS๊ฐ ์ธ๊ตญํ์ฌ๋ค ๋ณด๋ ํ์ฌ์์ ๋ฒ์ ์ธ ์๊ฑด์ด ์ถฉ์กฑ๋์ง ์๋ ๊ฒฝ์ฐ๊ฐ ๋ง์ต๋๋ค. ์ด๋ฐ ์ด์ ๋๋ฌธ์ Naver์์ ์ ๊ณตํ๋ ํด๋ผ์ฐ๋ ์๋น์ค์ธ NCP๋ฅผ ์ฌ์ฉํ๊ธฐ๋ ํฉ๋๋ค. (NCP ์ฌ์ฉ๋ฒ์ ์๋ ์์ ์ฐธ๊ณ ) ์ฌ์ฉ๋ฒ์ ์ด๋ค ํด๋ผ์ฐ๋ ์๋น์ค๋ฅผ ์ฌ์ฉํ์๋ ์ง ๋๋ถ๋ถ ์ ์ฌํฉ๋๋ค.
- ํด๋ผ์ฐ๋ ์๋ฒ๋ฅผ ํ ๋น๋ฐ๋๋ค.
- ์๋น์ค์ ๊ด๋ จ์๋ ์๋ฒ๋ค์ ์ฐ๊ฒฐํ๋ค.
- ์๊ฒฉ ์ ์ํ์ฌ ์ฝ๋๋ฅผ ๋ฐฐํฌํ๋ค.
ย
- ์ฝ์์์ โLightsailโ ๊ฒ์ ํ ํด๋ฆญ, letโs get started ๋๋ฌ์ฃผ์ธ์.
ย
- ๋ง์ฝ ์ด์ํ๊ณ ์๋ ์๋น์ค๊ฐ ์๋ค๋ฉด ์๋์ ๊ฐ์ด ๋ด์ ๊ฒ์ ๋๋ค. ์ธ์คํด์ค ์์ฑ์ ๋๋ฌ์ฃผ์ธ์. ์์ ๋์ผํ ํ์ด์ง๋ก ์ด๋ํฉ๋๋ค.
ย
- ์ ์ ๋ฐฉ๋ฒ์ ์น ์ ๊ทผ๊ณผ ์๊ฒฉ ์ ์์ด ์์ต๋๋ค.
- ์ธ์คํด์ค ์์ฑ(์ฐ๋ถํฌ๋ก ์์ฑํด ์ฃผ์ธ์.)
- ์ค์ ๊ณผ ๊ฐ๊ฒฉ(ํ๋ ์ ํ)
ย
- Cafe24์ ๋น๊ต
ย
- ์ธ์คํด์ค ์์ฑ ํ์ธ (IP๋ก ์ ์ํ๋ฉด ๋์๊ฐ๊ณ ์๋ ์๋น์ค๋ฅผ ํ์ธํ ์๋ ์์ต๋๋ค.)
ย
- ์ ์ ๊ธฐ๋ค๋ฆฌ๋ฉด ํ์ฑํ๋๋ฉฐ, ์น์์ ์ฝ์๋ก ์ ์ํ ์ ์์ต๋๋ค.
ย
- ์น์ผ๋ก ์ ์ํ๋ ๊ฒ์ด ํธํฉ๋๋ค. ์ปดํจํฐ์ key๋ฅผ ๋ค์ด๋ฐ๊ณ ssh๋ก ์ ์ํ๋ ๋ฐฉ๋ฒ๋ ์์ต๋๋ค.
ย
- ssh๋ก ์ ์ํ ๊ฒฝ์ฐ git์ ์ฌ์ฉํฉ์๋ค.(๋ช ๋ น์ด ํต์ผ์ ์ํด)
ย
- ๊ตฌ๋ฆIDE๋ฅผ ์ฌ์ฉํด๋ณด์ ์ ์ด ์์ผ์๋ค๋ฉด ๊ตฌ๋ฆIDE์ ssh ์ ์ ๋ช ๋ น์ด๋ ํ ๋ฒ ํ์ธํด๋ณด์ธ์. (๊ตฌ๋ฆIDE๋ AWS๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.)
ssh -p 53435 root@15.165.76.108
ย
- SSHํค ๋ค์ด๋ก๋
- ์ ์ ๋ช ๋ น์ด
ssh ubuntu@๋ด์๋ฒIP -i ./LightsailDefaultKey-ap-northeast-2.pem
- ๋ฆฌ๋
์ค ๋ช
๋ น์ด(
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/
- ํ์ผ ์์ ํ๊ณ ์ฌ๋ฌ๋ถ์ IP๋ก ์ ์ํด๋ณด์ธ์. ์ด๋ฏธ ์ ์ํด ์๋ ๊ฒฝ์ฐ ์๋ก๊ณ ์นจํ์ญ์์ค.
- route53 ๊ฒ์ ํ ๋๋ฉ์ธ ์ฐ๊ฒฐ (์ํ์ฝ๋ฉ ๊ฐ์ ์ถ์ฒํด๋๋ฆฝ๋๋ค. ํด๋น ๊ฐ์๋ AWS ํ์์ผ๋ก ๋ง๋ค์ด์ง ๊ฐ์์์.)
- ๋๋ฉ์ธ ๋ฑ๋ก
- DNS ๊ด๋ฆฌ
- ํธ์คํ ์์ญ ์์ฑ(๋ ์ฝ๋ ์ด๋ฆ๊ณผ ๊ฐ ์ ๋ ฅ)
ย
๋ถ๋ก
- Networking์์ Loadbalancer๋ฅผ ์ถ๊ฐํ๋ฉด ํ๋์ ์๋ฒ๊ฐ ๋ค์ด๋์์ ๋ ๋ค๋ฅธ ๋์ฒด ์๋ฒ๋ฅผ ์ค์ ํ ์ ์์ต๋๋ค. ์ด๊ฒ์ ์ฌ์ฉํ๊ธฐ ์ํด์๋ ์์ ์๋ฒ๋ฅผ ์ฌ๋ฌ๊ฐ ์์ฑํด๋์ด์ผ ํฉ๋๋ค.
ย
- ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ๋ณ๋๋ก ์ค์ ํ ์ ์์ต๋๋ค. ๋์ DB๋ ๊ฐ๊ฒฉ์ด ์กฐ๊ธ ๋๊ฐ๋๋ค.
- ์ค๋ ์ท ์ค์ ๋ ๊ฐ๋ฅํฉ๋๋ค. ๋งค์ผ ๋ฐค ๋ฐฑ์ ์ ํด์ฃผ๋ ๊ธฐ๋ฅ์ด์์.
ย
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 ์์ฑ ํ์.
ย
- ์๋ฒ ์ ํ ํ Create
- ์์ฑ๋ ์์ดํผ ๊ธฐ๋ก
- Node ํด๋ฆญ ํ Networking ํญ์ผ๋ก ์ด๋
- ์๋ add rule์ ํตํด 8080ํฌํธ Create
- ์์ฑ ํ์ธ
- ๊ณ ์ ์์ดํผ:8080์ผ๋ก ์ ์
ย
- node ๋ฐฐํฌ์ CSP ์ ์ฑ ์ ๋ฐ๋ผ ๋ฐฐํฌ๊ฐ ์ ๋๋ก ์๋๋(CSS๊ฐ ์ ๋๋ก ๋ณด์ด์ง ์๋) ํ์์ด ์์ ์ ์์ต๋๋ค. ํ๋ก์ ํธ๋ง๋ค ์๋ ๊ธ์ ๋ฐ๋ผ ์กฐ์นํด์ฃผ์๋ฉด ๋ฉ๋๋ค.
- ์ ์กฐ์น๋ก๋ ์๋๋ ๊ฒฝ์ฐ๋ ์๋ ์ฌํญ์ ์ฐธ๊ณ ํด์ฃผ์ธ์.
app.use(helmet())
์ฝ๋ ์ญ์ (์๋ ์ฝ๋๋ฅผ ๋ชจ๋ ์ ๋ ฅํ ๊ฒ๊ณผ ๊ฐ์ต๋๋ค.)- ์๋ ์ฝ๋ ์ถ๊ฐ
app.use(helmet({ contentSecurityPolicy:false, }));
4. AWS S3
๋ถ๋ก : AWS s3์์ ์ ์ ํ์ด์ง ํธ์คํ ํ๊ธฐย
ย