โ ํด์ปค๋ 7,8๋ช ์ ๊ฐ๋ฐ์๋ค์ด 1๋ ๋์ ์ด๋ ต๊ฒ ๊ฐ๋ฐํ๋ ๊ฒ๋ค์ ๋จ ๋ช๋ฌ ๋ง์ ํผ์์ ๊ฐ๋ฐํ ์ ์๋ ์ฌ๋์ ๋งํ๋ค.
IBM์ ์ด๋ค ํ๋ก๊ทธ๋๋จธ๋ค์ ๋ค๋ฅธ ์ด๋ค๋ณด๋ค 100๋ฐฐ ์ด์์ ๋ ๋ง์ ์ผ์ ํ ์ ์๋ค๊ณ ๋ณด๊ณ ํ์๋ค. โ- Peter Seebach
Unix ์ ๋ฌธ ํ ํฌ ์ ๋๋ฆฌ์คํธ

๊ธฐ์กด http ์๋ฒ
const http = require('http');
http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
res.write('<h1>Hello Node!</h1>');
res.end('<p>Hello Server!</p>');
})
.listen(8080, () => { // ์๋ฒ ์ฐ๊ฒฐ
console.log('8080๋ฒ ํฌํธ์์ ์๋ฒ ๋๊ธฐ ์ค์
๋๋ค!');
});
http ssl ์๋ฒ
const https = require('https');
const fs = require('fs');
https.createServer({
// ์ธ์ฆ๊ธฐ๊ด์ผ๋ก๋ถํฐ ๋ฐ๊ธ๋ฐ์ ์ธ์ฆ์ cert,key,caํ์ผ๋ค์ ๊ฐ์ ธ์จ๋ค.
// ๋ง์ผ ์ธ์ฆ์๋ฅผ ์๋ฃ์ผ๋ฉด ๋นจ๊ฐ ์๋ฌผ์ ๊ฒฝ๊ณ ๊ฐ ๋จ๊ฒ ๋๋ค.
cert: fs.readFileSync('๋๋ฉ์ธ ์ธ์ฆ์ ๊ฒฝ๋ก'), // ์ด๊ธฐํ ๋ก์ง์ด๋ ๋๊ธฐ๋ก ์ฒ๋ฆฌ
key: fs.readFileSync('๋๋ฉ์ธ ๋น๋ฐํค ๊ฒฝ๋ก'),
ca: [
fs.readFileSync('์์ ์ธ์ฆ์ ๊ฒฝ๋ก'),
fs.readFileSync('์์ ์ธ์ฆ์ ๊ฒฝ๋ก'),
],
}, (req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
res.write('<h1>Hello Node!</h1>');
res.end('<p>Hello Server!</p>');
})
.listen(443, () => { // https๋ ํฌํธ๊ฐ 443์ด๋ค.
console.log('443๋ฒ ํฌํธ์์ ์๋ฒ ๋๊ธฐ ์ค์
๋๋ค!');
});
http2 ์๋ฒ
- SSL ์ํธํ์ ๋๋ถ์ด ์ต์ HTTP ํ๋กํ ์ฝ์ธ http/2๋ฅผ ์ฌ์ฉํ๋ ๋ชจ๋
- ์์ฒญ ๋ฐ ์๋ต ๋ฐฉ์์ด ๊ธฐ์กด http/1.1๋ณด๋ค ๊ฐ์ ๋จ
- ์น์ ์๋๋ ๊ฐ์ ๋จ
- ๊ทธ๋ฆผ๊ณผ ๊ฐ์ด ์์ฒญํ์ผ์ ๋์์ ๋ณด๋

const http2 = require('http2'); // http2 ๋ชจ๋
const fs = require('fs');
// http2๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ๊ณ , ๋๋จธ์ง๋ https์ ๊ฐ๋ค.
http2.createSecureServer({
cert: fs.readFileSync('๋๋ฉ์ธ ์ธ์ฆ์ ๊ฒฝ๋ก'),
key: fs.readFileSync('๋๋ฉ์ธ ๋น๋ฐํค ๊ฒฝ๋ก'),
ca: [
fs.readFileSync('์์ ์ธ์ฆ์ ๊ฒฝ๋ก'),
fs.readFileSync('์์ ์ธ์ฆ์ ๊ฒฝ๋ก'),
],
}, (req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
res.write('<h1>Hello Node!</h1>');
res.end('<p>Hello Server!</p>');
})
.listen(443, () => {
console.log('443๋ฒ ํฌํธ์์ ์๋ฒ ๋๊ธฐ ์ค์
๋๋ค!');
});
์ธ์ฉํ ๋ถ๋ถ์ ์์ด ๋ง์ผ ๋๋ฝ๋ ์ถ์ฒ๊ฐ ์๋ค๋ฉด ๋ฐ๋์ ์๋ ค์ฃผ์๋ฉด ๊ฐ์ฌํ๊ฒ ์ต๋๋ค
์ด ๊ธ์ด ์ข์ผ์ จ๋ค๋ฉด ๊ตฌ๋ & ์ข์์
์ฌ๋ฌ๋ถ์ ๊ตฌ๋
๊ณผ ์ข์์๋
์ ์์๊ฒ ํฐ ํ์ด ๋ฉ๋๋ค.