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.
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:
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.