• Stars
    star
    451
  • Rank 93,847 (Top 2 %)
  • Language
    Shell
  • License
    MIT License
  • Created almost 9 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An Ngrok v2 container based on wizardapps/ngrok and fnichol/ngrok

Docker repository Build passing

Supported tags and respective Dockerfile links

A Docker image for ngrok v2, introspected tunnels to localhost. It's based on the excellent work of wizardapps/ngrok and fnichol/ngrok.

Features

  • Small: Built using Alpine.
  • Simple: Just link as http or https in most cases, see below; exposes ngrok server 4040 port.
  • Secure: Runs as non-root user with a random UID 6737 (to avoid mapping to an existing UID).

Configuration

To see command-line options, run docker run --rm wernight/ngrok ngrok --help.

Usage

Supposing you've an Apache or Nginx Docker container named web_service_container listening on port 80:

$ docker run --rm -it --link web_service_container wernight/ngrok ngrok http web_service_container:80

Environment variables

Please consider using directly the command-line arguments of Ngrok.

If you use the default CMD (i.e. don't specify the ngrok command-line but only wernight/ngrok), then you can use instead envrionment variables magic below.

You simply have to link the Ngrok container to the application under the app or http or https aliases, and all of the configuration will be done for you by default.

Additionally, you can specify one of several environment variable (via -e) to configure your Ngrok tunnel:

  • NGROK_AUTH - Authentication key for your Ngrok account. This is needed for custom subdomains, custom domains, and HTTP authentication.
  • NGROK_SUBDOMAIN - Name of the custom subdomain to use for your tunnel. You must also provide the authentication token.
  • NGROK_HOSTNAME - Paying Ngrok customers can specify a custom domain. Only one subdomain or domain can be specified, with the domain taking priority.
  • NGROK_REMOTE_ADDR - Name of the reserved TCP address to use for a TCP tunnel. You must also provide the authentication token.
  • NGROK_USERNAME - Username to use for HTTP authentication on the tunnel. You must also specify an authentication token.
  • NGROK_PASSWORD - Password to use for HTTP authentication on the tunnel. You must also specify an authentication token.
  • NGROK_PROTOCOL - Can either be HTTP, TLS or TCP, and it defaults to HTTP if not specified. If set to TCP, Ngrok will allocate a port instead of a subdomain and proxy TCP requests directly to your application.
  • NGROK_PORT - Port to expose (defaults to 80 for HTTP protocol, 443 for TLS protocol). If the server is non-local, the hostname can also be specified, e.g. 192.168.0.102:80 or dev.local:443.
  • NGROK_REGION - Location of the ngrok tunnel server; can be us (United States, default), eu (Europe), ap (Asia/Pacific) or au (Australia)
  • NGROK_LOOK_DOMAIN - This is the domain name referred to by ngrok. (default: localhost).
  • NGROK_BINDTLS - Toggle tunneling only HTTP or HTTPS traffic. When true, Ngrok only opens the HTTPS endpoint. When false, Ngrok only opens the HTTP endpoint
  • NGROK_HEADER - Rewrites the Host header for incoming HTTP requests to determine which development site to display.
  • NGROK_DEBUG - Toggle output of logs. When true, Ngrok will output logs to stdout.

Full example

  1. We'll set up a simple example HTTP server in a docker container named www:

    $ docker run -v /usr/share/nginx/html --name www_data busybox true
    $ docker run --rm --volumes-from www_data busybox /bin/sh -c 'echo "<h1>Yo</h1>" > /usr/share/nginx/html/index.html'
    $ docker run -d -p 80 --volumes-from www_data --name www nginx
    $ curl $(docker port www 80)
    <h1>Yo</h1>
    
  2. Now we'll link that HTTP server into an ngrok container to expose it on the internet:

    $ docker run -d -p 4040 --link www:http --name www_ngrok wernight/ngrok
    
  3. You can now access the API to find the assigned domain:

    $ curl $(docker port www_ngrok 4040)/api/tunnels
    

    or access the web UI to see requests and responses:

    $ xdg-open http://$(docker port www_ngrok 4040)
    

Helper

For common cases you may want to create an alias in your ~/.profile (or ~/.bashrc, ~/.zshrc, or equivalent):

function docker-ngrok() {
  docker run --rm -it --link "$1":http wernight/ngrok ngrok http http:80
}
# For ZSH with Oh-My-Zsh! and 'docker' plugin enabled, you can also enable auto-completion:
#compdef __docker_containers docker-ngrok

Then to run the simple example just do docker-ngrok web_service_container.

For non dockerized http targets consider this helper function:

function expose-ngrok() {
  docker run --rm --net=host -e NGROK_PORT="$1" wernight/ngrok
}

and then visit localhost:4040 for receiving the links.

Feedbacks

Report issues/questions/feature requests on GitHub Issues.

Pull requests are very welcome!

More Repositories

1

powerline-web-fonts

Powerline Web Fonts for Chromebook
HTML
207
star
2

docker-mopidy

Containerized Mopidy MPD (Music Player Daemon) along with Spotify, Google Music... plugins.
Dockerfile
155
star
3

docker-funbox

Docker container with fun terminal commands and ASCII art.
Shell
140
star
4

docker-dante

Dante SOCKS proxy server
Dockerfile
129
star
5

docker-plex-media-server

Dockerized Plex Media Server
Shell
127
star
6

renameit

Rename-It! is a Windows software to safely rename of thousands of files and folders at once via regex and all kind of other renaming filters. See the wiki section for more details.
C++
104
star
7

docker-youtube-dl

Dockerized youtube-dl based on Alpine Linux.
Dockerfile
80
star
8

docker-kubectl

Containerized Kubernetes kubectl
54
star
9

scruffy-server

Scruffy micro web server to have your own UML class/sequence diagram page like yUML and even more lean.
Smarty
44
star
10

docker-duplicity

Dockerize "duplicity" backup tool.
Dockerfile
36
star
11

docker-alpine-nginx-pagespeed

Dockerized Nginx with PageSpeed Module on Alpine Linux
29
star
12

docker-cpuminer-multi

Dockerized cpuminer-multi a multiple crypto currency miner.
Dockerfile
28
star
13

kubernetes-che

Example deploying Eclipse Che on a Kubernetes cluster
20
star
14

docker-compose

Minimal docker-compose based on Alpine Linux.
Dockerfile
19
star
15

docker-bfgminer

Dockerized BFGMiner
9
star
16

docker-squid

Dockerized Squid forward proxy
8
star
17

docker-trafficserver

Dockerized Apache Traffic Server
7
star
18

docker-kubernetes-dind

Kubernetes and Docker Registry in a Docker-in-Docker
Shell
6
star
19

gerrit-hooks-examples

Gerrit Hooks Examples
Python
5
star
20

docker-mitmproxy

Containerized mitmproxy (man-in-the-middle proxy) on top of Alpine Linux.
4
star
21

docker-sikulix

Dockerized SikuliX
4
star
22

docker-spdyproxy

Dockerized SPDY forwarding proxy.
Shell
3
star
23

mountnfall

Simple board game written in Java.
Java
2
star
24

vs-project-dependency-graph

Visual Studio 2008, 2010 and 2012 project dependencies visualization and graph.
C#
2
star
25

reverse-proxy

Setups virtual host reverse proxies on a Linux machine without root (good for Docker).
Shell
2
star
26

docker-ncmpcpp

Containerized ncmpcpp (MPC console client).
Dockerfile
1
star
27

glpong

Simple OpenGL game inspired by the classic pong.
C
1
star
28

git-example-hooks

Example Git hooks doing mostly Push-to-Deploy.
Python
1
star
29

bigle3d

Stereogram generator, a Windows application in C++
C++
1
star