Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to expose two ports using ngrok?

Tags:

server

ngrok

I have a local server on which my two services are running on port 8000 and 5500. I would like to expose both ports to the outer world. For the same I am using ngrok to expose both the ports. But it is exposing only one port i.e.8000.

I tried writing a yaml file in which I have written both the ports which I want to expose.

authtoken: "token"
tunnels:
  first:
    addr: 8000
    proto: http
  second:
    addr: 5500
    proto: http

I would like to expose both the ports(i.e. 8000 and 5500) so that I can see both the services running. Please guide me if I am exposing it properly or is there a better way around.

like image 841
Gaurang Patel Avatar asked Jun 28 '19 12:06

Gaurang Patel


People also ask

Does Ngrok open ports?

The connection tunnel established by ngrok is secure and can only transmit data to the localhost port you have open. It would be difficult to do any damage, but it's only as secure as the application you're testing.

Can a domain have multiple ports?

Yes, that's quite doable. The port is part of the vhost / site, so those are technically three different sites, and Caddy will happily serve all of them. I believe with that configuration Caddy will try to requisition a certificate and serve those sites over HTTPS on the ports you specified.

How to expose multiple ngrok tunnels at once?

Each “ngrok link” is a tunnel, if you want to expose multiple tunnels at once (next-facebook.local and boring-business-app.local) you need to use a configuration file, this file is stored in ~/.ngrok.yml, ngrok uses a YAML file for its configuration, here is an example of a configuration file that expostes two tunnels to internal domains.

What is ngrok and how does it work?

This is where ngrok comes into play. Ngrok allows us to expose a web server running on our local machine to the internet. We just need to tell ngrok on what port number our local web server is listening.

Does ngrok allow multiple ports exposure?

Free version of ngrok does not allow multiple ports exposure. Doesn't work with free ngrok account because different URLs would be assigned to first and second. One ngrok url can be bound to only one localhost app at a given time. It can't redirect traffic or deliver webhooks to two different localhost apps simultaneously.

How to open ngrok http 8080 from local port?

Double click on “ngrok.exe” Execute the below command on the opened command prompt (Assuming the locally up server port is 8080) ngrok http 8080 You can use the highlighted URLs as the Public URLs for the given local port


1 Answers

One ngrok url can be bound to only one localhost app at a given time. It can't redirect traffic or deliver webhooks to two different localhost apps simultaneously.

Ngrok's job is simple - to redirect traffic from ONE ngrok url to ONE localhost - it will not help you if it's hard to register multiple urls.

Content of config file

authtoken: "token"
tunnels:
  app-foo:
    addr: 80
    proto: http
    host_header: app-foo.dev
  app-bar:
    addr: 80
    proto: http
    host_header: app-bar.dev

Start ngrok :

ngrok start --all
like image 193
Bayu Dwiyan Satria Avatar answered Sep 24 '22 00:09

Bayu Dwiyan Satria