ngrok Agent Configuration File
Overview
The ngrok agent supports an optional, YAML configuration file which provides you with the power to run multiple tunnels simultaneously as well as to tweak some of its more advanced settings.
Default Locations
The default location of the ngrok agent's configuration file varies based on your operating system. The easiest way to find the configuration file location is to run:
ngrok config check
which will validate and print the location of the configuration file.
For the main operating systems we support, their default file locations are:
- Linux:
"~/.config/ngrok/ngrok.yml"
- MacOS (Darwin):
"~/Library/Application Support/ngrok/ngrok.yml"
- Windows:
"%HOMEPATH%\AppData\Local\ngrok\ngrok.yml"
Config File Merging
The --config
flag in the ngrok
command allows you to specify one or more
ngrok configuration files to merge when starting the ngrok agent. The rules for
merging are as follows:
- Values from later configs override those from earlier configs. For example, if config1.yml and config2.yml both set
api_key
, then callingngrok http --config config1.yml,config2.yml 80
will use theapi_key
from config2.yml. - Lists are overwritten using the last value.
- Maps, including the
tunnels
map, are merged by key and in the case of a duplicate key, the latter value is taken.
Full Example
Below is an example configuration file with all the options filled in.
authtoken: 4nq9771bPxe8ctg7LKr_2ClH7Y15Zqe4bWLWF9p
api_key: 24yRd5U3DestCQapJrrVHLOqiAC_7RviwRqpd3wc9dKLujQZN
connect_timeout: 30s
console_ui: true
console_ui_color: transparent
dns_resolver_ips:
- 1.1.1.1
- 8.8.8.8
heartbeat_interval: 1m
heartbeat_tolerance: 5s
inspect_db_size: 104857600 # 100mb
inspect_db_size: 50000000
log_level: info
log_format: json
log: /var/log/ngrok.log
metadata: '{"serial": "00012xa-33rUtz9", "comment": "For customer alan@example.com"}'
proxy_url: socks5://localhost:9150
region: us
remote_management: false
root_cas: trusted
update_channel: stable
update_check: false
version: 2
web_addr: localhost:4040
tunnels:
website:
addr: 8888
basic_auth:
- "bob:bobpassword"
schemes:
- https
host_header: "myapp.ngrok.dev"
inspect: false
proto: http
domain: myapp.ngrok.dev
e2etls:
addr: 9000
proto: tls
domain: myapp.example.com
crt: example.crt
key: example.key
policyenforced:
policy:
inbound:
- name: LimitIPs
expressions:
- "conn.ClientIP != '1.1.1.1'"
actions:
- type: deny
addr: 8000
proto: tcp
ssh-access:
addr: 22
proto: tcp
remote_addr: 1.tcp.ngrok.io:12345
my-load-balanced-website:
labels:
- env=prod
- team=infra
addr: 8000
Tunnel configurations
The most common use of the configuration file is to define tunnel configurations. Defining tunnel configurations is useful because you may then start pre-configured tunnels by name from your command line without remembering all of the right arguments every time. You may also use this method to start as many tunnels as you like from a single ngrok agent.
Tunnels are defined as mapping of name -> configuration under the tunnels
property in your configuration file.
Define two tunnels named 'httpbin' and 'demo'
tunnels:
httpbin:
proto: http
addr: 8000
domain: alan-httpbin.ngrok.dev
demo:
proto: http
addr: 9090
domain: demo.inconshreveable.com
inspect: false