How to enable both http and https tunnels in ngrok? - ngrok

The ngrok help doc says: line 3: Only HTTPS tunnels by default - ngrok agent HTTP tunnels by default will only open a single HTTPS endpoint for your upstream service instead of both an HTTP and HTTPS endpoint. To enable both, you will need to add --scheme http --scheme https to your ngrok agent command or configuration file.
I tried to update the configuration file, but no success. I got "ERROR: line 3: field schemes not found in type config.v2yamlConfig"
version: "2"
authtoken: faswETNh3FAW8DSmVuHrOH18s_6pK7iuqkQP5
schemes: http,https
I also tried the following. I got "ERROR: line 3: field scheme not found in type config.v2yamlConfig"
version: "2"
authtoken: faswETNh3FAW8DSmVuHrOH18s_6pK7iuqkQP5
scheme: http,https

The Ngrok version 3.0.0 has renamed bind_tls to schemes ngrok changelog:
changelog
Try this:
version: 2
authtoken: <TOKEN>
tunnels:
rails:
proto: http
addr: 5000
schemes: [https, http]
react:
proto: http
addr: 8080
schemes: [https, http]

Related

how to fix more than 3 tunnels are running over a single NGROK agent session

$
grok start --all
Your account may not run more than 3 tunnels over a single ngrok agent session.
The tunnels already running on this session are:
tn_2HpYCEfpJb2VAiIPS, tn_2HpYCKQh6q9j9R3nyKiJ, tn_2HpYCIPYGWWN9f3am75
ERR_NGROK_324
I tried to stop the running process but I could not.
I searched everywhere but had no luck.
thanks
Ngrok automatically opens a http and https tunnel for every configuration.
Add bind_tls:true to your configs to only open an https tunnel.
This way you can open three connections.
Example configuration:
tunnels:
first_service:
addr: 4200
proto: http
bind_tls: true
second_service:
addr: 8080
proto: http
bind_tls: true
third-service:
addr: 8085
proto: http
bind_tls: true

How to start all tunnels defined in ngrok.yaml PyNgrok

I have a custom config here is the sample:
log_level: info
region: ap
tunnels:
http:
addr: 5000
proto: http
ssh:
addr: 22
proto: tcp
I specify the config path on pyngrok but when I try to run ngrok.connect() only HTTP part is working and show on my ngrok dashboard, no ssh tunnel. When I try the ngrok binary provided by pyngrok:
ngrok start --all --config=/ngrok.yaml
It works! On my ngrok dashboard I have HTTP, HTTPS and TCP.
These commands do not map to each other, which is why they do not do the same thing. connect() calls ngrok start --none, so it starts the ngrok process and API with no tunnels running, then it starts a tunnel using the API with the params you've passed to connect(). To start multiple tunnels, just call connect() more than once with different params.
from pyngrok import ngrok
conf.get_default().region = "ap"
tunnel1 = ngrok.connect(addr=5000)
tunnel2 = ngrok.connect(addr=22, proto="tcp")
In the above example, the config file isn't even necessary. If you already have tunnel definitions in your config though, you can use them by just passing their name.
from pyngrok import ngrok
conf.get_default().config_path = "/ngrok.yml"
tunnel1 = ngrok.connect(name="http")
tunnel1 = ngrok.connect(name="tcp")
The docs, which have many examples of this and other usage, can be found here.

Ngrok inbuilt file server configuration through config file

Ngrok servers a folder using inbuild server when we run the following in command line
ngrok http file://<path to file>
I am trying to configure more tunnels like ssh in the same machine using config files like
tunnels:
httpbin:
proto: http
file: "//<path to file>" ##THIS IS ERROR ##
demo:
proto: ssh
addr: 22
is does not seems to be possible to configure inbuild file sharing using a configuration file in ngrok. Or is there some way?
You try this steps:
https://dashboard.ngrok.com/get-started/your-authtoken and login
Terminal and run: ngrok authtoken token_id
result: Authtoken saved to configuration file: /home/user/.ngrok2/ngrok.yml
Terminal: ngrok http file:///home
Finish !
result: https://i.stack.imgur.com/FPZbP.png
ngrok doc: https://ngrok.com/docs
Actually just stumbled across it by accident. A bit of experimentation, and no guarantees that it will continue to work since it's not mentioned in the docs. Just use the file: protocol in the addr yaml option.
authtoken: <REDACTED>
tunnels:
dev2:
proto: http
addr: file:///some/path/just/like/command/line
hostname: my-great-subdomain.ngrok.io

How to make ngrok client listen a specific hostname instead of localhost?

My yaml config is like this:
yarn:
hostname: "ngrok.xfl.me:810"
remote_port: 810
proto:
tcp: 8088
My purpose is:
Forwarding https://ngrok.xfl.me:810-> 192.168.0.104:8088
But by default, as the config above, ngrok client just listen to 127.0.0.1. So it failed to connect.
How can I make the ngrok client listen to a certain hostname 192.168.0.104 instead of localhost
Thanks a lot!
It was solved with:
yarn:
hostname: "ngrok.xfl.me:810"
remote_port: 810
proto:
tcp: 192.168.0.104:8088

ngrok not running due to proxy

I have ngrok installed on Ubuntu. I want to expose an application at 8080. The machine is behind a corporate proxy. I exported an environment variable http_proxy with the proxy value and tried to run the command:
./ngrok http 8080
The status remains reconnecting and the error says "Proxy Authorization required".
I have also tried it using a ngrok.yml config file with the proxy value. And specified the path of the file:
./ngrok http -config=./ngrok.yml 8080
This is how the config file looks:
console_ui: true
inspect_db_size: 50000000
log_level: debug
log_format: json
log: /var/log/ngrok.log
http_proxy: "http://username:password#proxyhost.co.in:8080"
tunnels:
jenkins:
addr: 8080
bind_tls: true
inspect: false
proto: http
Still the error persists. Inspite of specifying the correct proxy, its failing. Any help would be appreciated.
open CMD. And type this:
set http_proxy=
set https_proxy=
There should be the following entry:
authtoken: YOUR_NGROK_TOKEN
in the configuration file. Perhaps, due to its absence you get the error.
The token you can find from your ngrok-account, from dashboard.

Resources