ngrok 사용법

 

ngrokNAT와 방화벽 뒤에 있는 로컬 서버를 안전한 터널을 통해 공개 인터넷에 노출 시켜주는 도구이다.

즉, 포트 포워딩과 같은 네트워크 환경 설정 변경없이 로컬에 실행중인 서버를 안전하게 외부에서 접근 가능하도록 해주는 도구이다.

 

ngrok 공식 홈페이지 : https://ngrok.com/product

사용하는 때는 다음과 같다.

  • 로컬 환경에서 ssl을 사용하고 싶은 경우
  • localhost를 외부에서 호출하고 싶은 경우

 

설치 방법

1. ngrok 사이트에서 다운로드 받기(https://ngrok.com/download)
2. ngrok 압축 풀기
3. ngrok.exe가 설치된 경로에서 아래 명령어 실행하기

🍺MAC에서 brew로 설치하는 방법

더보기

mac - brew로 설치

 

$ brew cask install ngrok
==> Satisfying dependencies
==> Downloading https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-darwin-amd64.zip
######################################################################## 100.0%
==> No SHA-256 checksum defined for Cask 'ngrok', skipping verification.
==> Installing Cask ngrok
==> Linking Binary 'ngrok' to '/usr/local/bin/ngrok'.
🍺  ngrok was successfully installed!

 

설치 확인

$ ngrok --help

NAME:
   ngrok - tunnel local ports to public URLs and inspect traffic

DESCRIPTION:
    ngrok exposes local networked services behinds NATs and firewalls to the
    public internet over a secure tunnel. Share local websites, build/test
    webhook consumers and self-host personal services.
    Detailed help for each command is available with 'ngrok help <command>'.
    Open http://localhost:4040 for ngrok's web interface to inspect traffic.

EXAMPLES:
    ngrok http 80                    # secure public URL for port 80 web server
    ngrok http -subdomain=baz 8080   # port 8080 available at baz.ngrok.io
    ngrok http foo.dev:80            # tunnel to host:port instead of localhost
    ngrok tcp 22                     # tunnel arbitrary TCP traffic to port 22
    ngrok tls -hostname=foo.com 443  # TLS traffic for foo.com to port 443
    ngrok start foo bar baz          # start tunnels from the configuration file

VERSION:
   2.2.8

AUTHOR:
  inconshreveable - <alan@ngrok.com>

COMMANDS:
   authtoken	save authtoken to configuration file
   credits	prints author and licensing information
   http		start an HTTP tunnel
   start	start tunnels by name from the configuration file
   tcp		start a TCP tunnel
   tls		start a TLS tunnel
   update	update ngrok to the latest version
   version	print the version string
   help		Shows a list of commands or help for one command

 

실행하기

windows

./ngrok.exe http [open with live server의 포트번호 입력]

mac or linux

./ngrok http [open with live server의 포트번호 입력]

npm으로 실행하기

npm install -g ngrok
ngrok http [open with live server의 포트번호 입력]

 

Session Expire
  • 한 세션은 8시간 후 만료된다.
  • 회원가입 후 아래 링크에서 AuthToken을 가져와 입력한 후 실행하면 세션 만료없이 사용할 수 있다.
    AuthToken 가져오기
./ngrok http [open with live server의 포트번호 입력] AuthToken값

 

 

 

 

 

* Refernce

[블로그]

[Github]