Methods of payment Abuse

Configuring tunnels in the Ngork configuration file

06.01.2023, 14:15

Ngrok has a configuration file, it contains the authorization token. Often while working with the software there is a need to run a command, it is quite long, so to shorten the tunnel start command you can use a configuration file.

Configuration file in Yaml format

The command can be described exactly in this file, and afterwards run by name. Ngrok stores the configuration in Yaml format in the home folder in the .config folder. But there is no need to edit the file directly. For editing there is config edit:

ngrok config edit

The tunnels section should be added to the config file.

The syntax for the tunnel description is as follows:

tunnels:
  tunnel_name:
    proto: protocol 
    addr: port

Other parameters that were previously passed on the command line are also available here:

  1. basic_auth - add HTTP authorization.
  2. host_header - replace the value of the Host header.
  3. inspect - whether to save requests for inspection, by default it is enabled.
  4. schemes - available schemes: http and/or https.
  5. specify your domain name for the service, available only in paid subscription.

To create an example tunnel for port 80, with the Host header replaced by example.local, add these lines to the tunnels section:

example:

proto: http

addr: 80

host_header: "example.local"

Now save the changes and check the configuration file with this command:

ngrok config check

If you have done everything correctly, you will see a message in the configuration file:

Next, you can run the configured tunnel by its name:

ngrok start example

Now you know how to create a command in the configuration file.