Back to TILs

ngrok

Date: 2022-12-12Last modified: 2023-02-17

ngrok is a globally distributed reverse proxy fronting your web services running in any cloud or private network, or your machine.

Installation

From https://ngrok.com/download copy the apt command:

curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc \
  | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null \
  | && echo "deb https://ngrok-agent.s3.amazonaws.com buster main" \
  | sudo tee /etc/apt/sources.list.d/ngrok.list \
  | && sudo apt update \
  | && sudo apt install ngrok

Account

Connecting your account according to https://dashboard.ngrok.com/get-started/setup:

ngrok config add-authtoken 2Ip...BYo
Authtoken saved to configuration file: /home/geraldo/.config/ngrok/ngrok.yml

Basic usage

Serving a webpage

Starting a server on localhost:

http-server ./

Expected output:

Starting up http-server, serving ./

http-server version: 14.0.0

http-server settings: 
CORS: disabled
Cache: 3600 seconds
Connection Timeout: 120 seconds
Directory Listings: visible
AutoIndex: visible
Serve GZIP Files: false
Serve Brotli Files: false
Default File Extension: none

Available on:
  http://127.0.0.1:8080
  http://192.168.15.35:8080
Hit CTRL-C to stop the server

Piping port 8080:

ngrok http 8080
Session Status  online
Account         Geraldo Ribeiro (Plan: Free)
Version         3.1.0
Region          South America (sa)
Latency         13ms
Web Interface   http://127.0.0.1:4040
Forwarding      https://118c-2804-431-c7db-f2a7-a31-6b93-92ee-3650.sa.ngrok.io -> http://localhost:8080

References