Reputation: 2883
Is it possible to open multiples ports in ngrok in same domain?
Something like:
Fowarding http://example.ngrok.com:50001 -> 127.0.0.1:50001
Fowarding http://example.ngrok.com:50002 -> 127.0.0.1:50002
I´m working in windows and it'll be useful for debuging with IIS Express
Upvotes: 145
Views: 171351
Reputation: 306
The following code snippet works with the latest Ngrok version 3.
version: "3"
tunnels:
first:
addr: 4000
proto: http
second:
addr: 5000
proto: http
agent:
authtoken: your_private_token
Upvotes: 0
Reputation: 3947
Yes, it is possible using multiple simultaneous tunnels, within the same hostname
!
All you need to do, is to declare them on your configuration file, like this:
authtoken: 4nq9771bPxe8ctg7LKr_2ClH7Y15Zqe4bWLWF9p
tunnels:
first-app:
addr: 50001
proto: http
hostname: example.ngrok.com
host_header: first-app.example.ngrok.com
second-app:
addr: 50002
proto: http
hostname: example.ngrok.com
host_header: second-app.example.ngrok.com
And run them with:
ngrok start --all
Look on the documentation for options, like hostname
, subdomain
, authtoken
and host_header
. Hope this help you !
P.S For Free plan remove custom host and header part like this it will be different domains FYI.
authtoken: 6yMXA63qefMZqCWSCHaaYq_5LufcciP1rG4LCZETjC6V
tunnels:
first:
addr: 3002
proto: http
second:
addr: 8080
proto: http
NOTES:
To find your default config file read https://ngrok.com/docs/agent/config/
.
All plans issues an auth token. You can find yours in the web dashboard: https://dashboard.ngrok.com/get-started/setup
Update: Nov 2024
for version 3, you need to do the following:
version: "3"
agent:
authtoken: 2pNn6oWWEWEsdasc7xveBp2Q1TaPpl_3Jut8L2p4wCsdfEEF9BEcUk
tunnels:
score_api:
proto: http
addr: 8000
weather_api:
proto: http
addr: 9801
Upvotes: 162
Reputation: 4408
You would need to have a paid account to expose more than one port from the same machine using NGROK.
Edit Ngrok configuration file ngrok.yml
Use this syntax:
version: 3
agent:
authtoken: 4nq9771bPxe8ctg7LKr_2ClH7Y15Zqe4bWLWF9p
endpoints:
- name: foo
description: foo123
metadata: foo123
url: foo.ngrok.io
upstream:
url: 8080
protocol: http1
- name: bar
url: bar.ngrok.io
upstream:
url: 8080
Then run this command to check for errors:
ngrok config check
and this command to start all tunnels or endpoints that are defined in your Ngrok configuration file
ngrok start --all
Upvotes: 1
Reputation: 516
I'm using a free plan
If you want to run multiple domains on https, this worked for me
ngrok config edit
version: "2"
authtoken: --your-ngrok-auth-token--
tunnels:
api1:
addr: https://localhost:8888
schemes:
- https
proto: http
api2:
addr: https://localhost:8080
schemes:
- https
proto: http
After that run
ngrok start --all
Upvotes: 4
Reputation: 696
Actually, at 2023, I'm just supporting the original answer.
And, showing how to edit the ngrok config file (ngrok.yml).
In CMD
do:
ngrok config edit
Something like this:
version: "2"
authtoken: your_token_here
tunnels:
any1:
addr: 8888
proto: http
any2:
addr: 8080
proto: http
any3:
addr: 50000
proto: http
Finally, again in CMD
, start ngrok:
ngrok start --all
Be happy!
Upvotes: 10
Reputation: 950
This is how you can do using subdomain
(Following @robe007 answer)
authtoken: your_auth_token
region: au
tunnels:
frontend:
proto: http
addr: http://localhost:3000
bind_tls: true
subdomain: frontend-my-domain
host_header: rewrite
backend:
proto: http
addr: http://localhost:5001
bind_tls: true
subdomain: backend-my-domain
host_header: rewrite
Then run ngrok start --all
Upvotes: 4
Reputation: 669
Go To These location :
/Users/example/.ngrok2/ngrok.yml
/home/example/.ngrok2/ngrok.yml
C:\Users\example\.ngrok2\ngrok.yml
then open yml file in notepad and paste below code and save.
authtoken: your_token
tunnels:
first:
addr: 3002
proto: http
second:
addr: 8080
proto: http
now go to your ngrok location and run ngrok start --all
Upvotes: 26
Reputation: 26086
So I had the issue where I needed the same domain origin policy to work for different ports but I was halted in my tracks because ultimately ngrok does not support this. They support a custom subdomain or custom domain but not on different ports since all must come through port 80 or 443.
Instead of quitting, I had to hack things together using nginx locally like so:
http {
server {
listen 7777;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:5000;
}
location /api {
proxy_pass http://127.0.0.1:8000;
}
}
}
I was fortunate the api server prefixed all calls "api" so I could route the api calls to a specific port and still serve the other traffic on another web server and you may not be so lucky.
I then configured the public web server to route all api calls to the same ngrok address and let ngnix sort it out.
I hope this may help you think of a combination of solutions to get there as thinking only one way may get you stuck as I was.
Upvotes: 43
Reputation: 105
Unfortunatly none of the following solutions worked for me but after multiple hours typing code with my nose i figured a way to solve this problem:
authtoken: your_private_token tunnels: baseAPI: proto: http addr: https://localhost:44307/ host_header: localhost:44307 authAPI: proto: http addr: https://localhost:44305/ host_header: localhost:44305
The diference is instead of using only the port on the addr
field, i used the full link and added the host_header
too.
Upvotes: 6
Reputation: 39
I used on ngrok process (on a reserved domain) pointing to port 80 locally.
ngrok http 80
Locally I have nginx running the following config. The only thing that matters to me are the 2 locations /admin and /api as those are what I was previously using multiple ngrok prcesses for. nginx allows you to use the same tunnel for separate locations.
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
server_name _;
location /admin {
proxy_pass http://127.0.0.1:3005;
}
location /api {
proxy_pass http://127.0.0.1:5001;
}
}
Upvotes: 3