├── .envrc ├── .gitignore ├── CONTRIBUTING.md ├── default.nix ├── flake.nix ├── releases.json ├── alpine.nix ├── scripts └── entrypoint.sh ├── debian.nix ├── LICENSE ├── flake.lock └── README.md /.envrc: -------------------------------------------------------------------------------- 1 | dotenv_if_exists 2 | use flake 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | .direnv 3 | result* 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Development 2 | 3 | Images can be built locally by running `nix-build` from the repo root. (You'll need to have [nix](https://nixos.org/download.html) installed) 4 | -------------------------------------------------------------------------------- /default.nix: -------------------------------------------------------------------------------- 1 | (import 2 | ( 3 | let 4 | lock = builtins.fromJSON (builtins.readFile ./flake.lock); 5 | in 6 | fetchTarball { 7 | url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; 8 | sha256 = lock.nodes.flake-compat.locked.narHash; 9 | } 10 | ) 11 | { 12 | src = ./.; 13 | }).defaultNix.packages.x86_64-linux 14 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "The ngrok docker container"; 3 | 4 | inputs = { 5 | nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; 6 | flake-utils.url = "github:numtide/flake-utils"; 7 | flake-compat = { 8 | url = "github:edolstra/flake-compat"; 9 | flake = false; 10 | }; 11 | }; 12 | 13 | outputs = 14 | { 15 | self, 16 | nixpkgs, 17 | flake-utils, 18 | ... 19 | }: 20 | let 21 | pkgs = import nixpkgs { 22 | system = "x86_64-linux"; 23 | }; 24 | in 25 | { 26 | packages.x86_64-linux = pkgs.callPackage ./build.nix { }; 27 | devShells.x86_64-linux.default = pkgs.mkShell { }; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /releases.json: -------------------------------------------------------------------------------- 1 | { 2 | "amd64": { 3 | "url": "https://bin.equinox.io/a/kUjNE8heii/ngrok-v3-3.34.1-linux-amd64.zip", 4 | "sha256": "f835fca84cb12ebd6356e3721de167415a3c49d52b814f7b560609bd2ec18212" 5 | }, 6 | "arm": { 7 | "url": "https://bin.equinox.io/a/mWoi4Poa7ey/ngrok-v3-3.34.1-linux-arm.zip", 8 | "sha256": "be928711f3c40df5f6208de1adb86732318c08957a2d9aee0e881ddf94bbfd0b" 9 | }, 10 | "arm64": { 11 | "url": "https://bin.equinox.io/a/3YgkxkCD6PT/ngrok-v3-3.34.1-linux-arm64.zip", 12 | "sha256": "0969393eda54091b97cb7aac46c57aa8ce49affb53f4736cd57be2aa9ed0e23a" 13 | }, 14 | "i386": { 15 | "url": "https://bin.equinox.io/a/g4wQTYWKzgu/ngrok-v3-3.34.1-linux-386.zip", 16 | "sha256": "cbbd932c681ccaa15270eebb8df3341e413caf28be90ee98f2a40457bc764761" 17 | }, 18 | "version": "3.34.1" 19 | } 20 | -------------------------------------------------------------------------------- /alpine.nix: -------------------------------------------------------------------------------- 1 | { pkgs, arch, entrypoint, ngrokBin, shadowSetup, extraCommands, version 2 | , imageDigest, imageSha256 }: 3 | 4 | with pkgs; 5 | let 6 | alpine = { imageDigest, sha256 }: 7 | dockerTools.pullImage { 8 | inherit arch imageDigest sha256; 9 | imageName = "alpine"; 10 | os = "linux"; 11 | finalImageName = "alpine"; 12 | finalImageTag = "3.14.0"; 13 | }; 14 | in dockerTools.buildLayeredImage { 15 | inherit extraCommands; 16 | name = "ngrok/ngrok"; 17 | tag = "${version}-alpine-${arch}"; 18 | fromImage = alpine { 19 | sha256 = imageSha256; 20 | inherit imageDigest; 21 | }; 22 | contents = [ ngrokBin entrypoint ] ++ shadowSetup; 23 | config = { 24 | ExposedPorts = { "4040" = { }; }; 25 | Entrypoint = [ "${entrypoint}/entrypoint.sh" ]; 26 | User = "ngrok"; 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /scripts/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | CONFIGDIR="/var/lib/ngrok" 3 | CONFIGARGS="" 4 | 5 | # Create and set a configuration file that defines the authorization token. 6 | if [ -n "$NGROK_AUTHTOKEN" ]; then 7 | cat > $CONFIGDIR/auth-config.yml <-debian` - Debian builds for specific versions of the ngrok agent. Available for every minor version from 2.3.40 and up. 25 | - `:-alpine` - Alpine builds for specific versions of the ngrok agent. Available for every minor version from 2.3.40 and up. 26 | - `:-debian-` - Immutable tags pointing to the Debian build of the ngrok agent for a specific version. Available for every build we release. 27 | - `:-alpine-` - Immutable tags pointing to the Alpine build of the ngrok agent for a specific version. Available for every build we release. 28 | 29 | ## Quick Start 30 | 31 | ### Linux 32 | 33 | ```bash 34 | # Forward a public endpoint URL to port 80 on your local machine 35 | docker run --net=host -it -e NGROK_AUTHTOKEN=xyz ngrok/ngrok:latest http 80 36 | ``` 37 | 38 | ### Windows or macOS 39 | 40 | ```bash 41 | docker run -it -e NGROK_AUTHTOKEN=xyz ngrok/ngrok:latest http host.docker.internal:80 42 | ``` 43 | 44 | For macOS and Windows, you must use the special URL `host.docker.internal` as described in the [Docker networking documentation](https://docs.docker.com/desktop/features/networking/#use-cases-and-workarounds). 45 | 46 | This also applies to the `upstream.url` endpoint property in your ngrok config file. For example: 47 | 48 | ```yml 49 | endpoints: 50 | - name: example 51 | url: https://example.ngrok.app 52 | upstream: 53 | url: http://host.docker.internal:80 54 | ``` 55 | 56 | ## Usage 57 | 58 | For usage, see [Using ngrok with Docker](https://ngrok.com/docs/using-ngrok-with/docker/). 59 | 60 | ## Configuration 61 | 62 | ### Environment Variables 63 | 64 | - `NGROK_AUTHTOKEN`: Your ngrok authentication token 65 | - `NGROK_CONFIG`: Path to configuration file (default: `/etc/ngrok.yml`). See: [config file docs](ngrok-config-docs) 66 | 67 | 68 | ## Upgrading to v3 69 | 70 | If you're using a v2 agent still, follow the [upgrade guide in our docs](https://ngrok.com/docs/guides/upgrade-v2-v3). 71 | 72 | 73 | #### How do I know what version my ngrok container image is? 74 | 75 | ```bash 76 | docker run -it ngrok/ngrok version 77 | ``` 78 | 79 | [ngrok-dockerhub]: https://hub.docker.com/r/ngrok/ngrok 80 | [ngrok]: https://ngrok.com/ 81 | [ngrok-docs]: https://ngrok.com/docs 82 | [ngrok-config-docs]: https://ngrok.com/docs/agent/config/ 83 | --------------------------------------------------------------------------------