Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Expose Local Services to Public Using ngrok

You can expose a local service to public using ngrok. Follow instructions in the official documentation of ngrok to setup ngrok.

  1. Install ngrok.

     sudo snap install ngrok
  2. Login to ngrok.com to identify your ngrok token.

  3. Connect your account following instructions.

     ngrok config add-authtoken your_token
  4. Start a http tunnel forwarding to you local port.

     ngrok http your_choice_of_port

For example, suppose you have launch a code-server service in your local network using the following command.

docker run -d --init \
    --hostname vscode-server \
    --log-opt max-size=50m \
    --memory=$(($(head -n 1 /proc/meminfo | awk '{print $2}') * 4 / 5))k \
    --cpus=$(($(nproc) - 1)) \
    -p 2020:8080 \
    -e DOCKER_USER=$(id -un) \
    -e DOCKER_USER_ID=$(id -u) \
    -e DOCKER_PASSWORD=$(id -un) \
    -e DOCKER_GROUP_ID=$(id -g) \
    -v "$(pwd)":/workdir \
    dclong/vscode-server /scripts/sys/init.sh

You can expose it to public via ngrok by running the following command.

ngrok http 2020

References