Full example
The following is a comprehensive configuration file for ngrok with detailed documentation for each option. To activate a specific option or tunnel, uncomment the relevant lines by removing the# at the beginning of the line.
Tunnel configurations
The most common use of the configuration file is to define tunnel configurations. Defining tunnel configurations is useful because you can then start pre-configured tunnels by name from your command line without remembering all of the right arguments every time. You can also use this method to start as many tunnels as you like from a single ngrok agent. You define tunnels as a mapping of name -> configuration under thetunnels property in your configuration file.
Define two tunnels named httpbin and demo:
httpbin:
--host-header becomes host_header: in the configuration file and --url becomes url).
Tunnels can define a specific proto or use labels to dynamically connect to one or more matching ngrok Edges.
All tunnels must define a specific addr that tells the agent where to send the traffic.
Other properties are available, and many are protocol-specific.
Start all tunnels defined in the configuration file:
Common tunnel configuration properties
HTTP configuration
TCP configuration
TLS configuration
Labeled tunnel configuration
Define two labeled tunnels:
Agent configuration
The following is a list of options that you can configure at the root of your configuration file to specify the behavior of the agent.api_key
This option specifies the API key used to access the ngrok API through the ngrok api command.
This is only needed when using the ngrok API and not the local ngrok agent API (available at localhost:4040/api).
You can generate an API Key in the ngrok dashboard and install it using the ngrok config add-api-key command.
An ngrok.yml file that specifies an API key:
authtoken
This option specifies the authentication token (sometimes called tunnel credential) used to authenticate this agent when it connects to the ngrok service.
After you’ve created an ngrok account, your dashboard displays the authtoken assigned to your account.
Your authtoken works on multiple machines if you’re just developing.
When you want to deploy many agents on many devices, you can generate a unique authtoken for each device in the ngrok dashboard or via the ngrok api credentials command.
An ngrok.yml file that specifies an authtoken:
connect_interface
Sets the specific network interface that the ngrok agent should use.
This is only supported on Linux platforms.
connect_timeout
How long to wait when establishing an agent session connection to the ngrok service.
This is specified as a duration, with the default being 10s.
console_ui
This option allows you to enable or disable the console UI that is displayed in your terminal window after starting ngrok.
console_ui_color
The command sets the background color when displaying the console UI in the terminal.
To choose a color other than black, set the value to transparent and change the background of your terminal window.
crl_noverify
This option skips verifying with the Certificate Revocation List if set to true.
This defaults to false.
crl_url
The URL the ngrok agent fetches the Certificate Revocation List (CRL) from.
The default is http://crl.ngrok-agent.com/ngrok.crl.
The URL must use the http or https scheme.
Set this option if your network blocks outbound connections on port 80.
For example, https://crl.ngrok-agent.com/ngrok.crl fetches the same CRL over HTTPS on port 443.
The agent verifies the CRL’s signature, so you can also serve a mirrored copy from your own host.
This option has no effect when crl_noverify is true.
Available in ngrok agent version 3.39.7 and later.
dns_resolver_ips
Consult these DNS servers for tunnel session DNS resolution.
By default, the ngrok agent uses the local system DNS servers to resolve.
heartbeat_interval
How often the ngrok agent should heartbeat to the ngrok servers defined as a duration.
The default is 10s.
heartbeat_tolerance
Reconnect the agent tunnel session if the server doesn’t respond to a heartbeat within this tolerance defined as a duration.
The default is 15s.
inspect_db_size
This is the upper limit in bytes on memory to allocate when saving requests over HTTP tunnels for inspection and reply.
The default is 0, which means 50MB.
log_level
This is the logging level of detail.
In increasing order of verbosity, possible values are: crit, warn, error, info, and debug.
log_format
This is the format of written log records.
log
This is the destination where ngrok should write the logs.
metadata
This is a user-supplied custom string that’s returned as part of the ngrok API response to the list online sessions resource for all tunnels started by this agent.
This is a useful mechanism to identify tunnels by your own device or customer identifier.
Maximum 4096 characters.
proxy_url
This is the URL of an HTTP or SOCKS5 proxy to use for establishing the tunnel connection.
Many HTTP proxies have connection size and duration limits that cause ngrok to fail.
Like many other networking tools, ngrok also respects the environment variable http_proxy and http_proxy_env if it’s set.
region
Deprecated This is the region the ngrok agent connects to.
You can only choose one region per agent session.
Choosing the region closest to you usually improves latency and performance.
By default, the ngrok agent attempts to choose the best region for you.
remote_management
Set this to true to allow the ngrok agent to be remotely managed (stop, restart, update) via the ngrok API or the ngrok dashboard.
Defaults to true.
root_cas
These are the root certificate authorities used to validate the TLS connection to the ngrok server.
server_addr
This is the URL of the ngrok server to connect to.
You should set this if you’re using a custom ingress URL.
tunnels
This is a map of names to tunnel definitions.
See tunnel definitions for more details.
update_channel
The update channel determines the stability of released builds to update to.
Use stable for all production deployments.
update_check
This tells the ngrok agent if it should check for updates.
Defaults to true.
version
Specifies the version of the config file to use.
web_addr
This is the network address to bind on for serving the local agent web interface and API.
web_allow_hosts
This is a list of specifiers for which Host headers can make requests against the local agent web interface and API.
The agent strips any port off the Host header before matching.
Allow an IP address and a domain as
Host headers: