NodeJS [2] - 웹서버구동, 외부IP 접근
NodeJS [2] - 웹서버구동, 외부IP 접근
서버는 Google Cloud를 이용한다.
IP는 외부IP로 접근할것이다.
vim 으로 만들어준다.
const http = require('http'); const hostname = '내부 ip 혹은 로컬주소'; const port =포트번호; http.createServer((req, res) => { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello World
'); }).listen(port, hostname, () => { console.log(`Server running at https://${hostname}:${port}/`); });
웹서버 실행!
안된다..
$sudo iptables -L
현재 열려있는 포트들의 확인
아무것도 열려있지 않다.
sudo iptables -I INPUT -p tcp --dport 3000 -j ACCEPT
$sudo iptables -I INPUT -p tcp --dport 3000 -j ACCEPT
열어준다
안된다...
google Cloud Platform - 방화벽검색
3000 포트에 대해서 아무도 허용을 해주지 않았다..
내가 허용해준다.
추가됬다!
다시 실행해보자
성공!
from http://parkbi.tistory.com/12 by ccl(A) rewrite - 2020-03-07 20:20:22
댓글
댓글 쓰기