Ngrok configure multiple port in same domain - iis-express

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

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#config-default-location.
All plans issues an auth token. You can find yours in the web dashboard: https://dashboard.ngrok.com/get-started

What worked for me with ngrok w/ multiple ports
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.

Go To These location :
OS X: /Users/example/.ngrok2/ngrok.yml
Linux: /home/example/.ngrok2/ngrok.yml
Windows: 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

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;
}
}

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

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.

Using free plan
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!

Related

Not able to Configure relay sentry setup with proxy

I want to connect relay to sentry.io via proxy service/application.
Please help me in this I am not able to find any way to put proxy between relay and sentry.
Config.yml
relay:
mode: managed
upstream: “https://sentry.io/”
host: 0.0.0.0
port: 3000
tls_port: ~
tls_identity_path: ~
tls_identity_password: ~
Where I have to set the proxy in relay?
You can replace the upstream location to your proxy service/application and there you need to have another relay which can upload the data to sentry.io
Warn : This will just forward the messages, so configure your first relay in proxy mode.

Exposing Nuxt/vue front and laravel back end local env with Ngrok

I have a local vue,nuxt enviroment that calls another local laravel api route. I am trying to expost the ports with ngrok.
My Nuxt/vue env
Nuxt config
// Axios module configuration (https://go.nuxtjs.dev/config-axios)
axios: {
baseURL: 'http://localhost:8001/api/'
},
I am able to expose both port 3001 as well as port 8001 with ngrok but it seem like my front end is unable to talk to my ngrok port 8001, does anyone have any pointers?
ngrok
port 3001
./ngrok http 3001
port 8001
./ngrok http 8001
Run ngrok for the laravel project
Then run it for nuxt/vue front-end

Laravel Forge - access app by naked IP instead of domain name

I have a laravel app on production (using Laravel Forge and a Digital Ocean droplet).
I'm able to access the app via www.domain.com, but if I try with the server's IP I get a 404 (nginx).
How can I manage to access the app with the IP address?
Thanks a lot for your help
EDIT:
Here is my Nginx config on Laravel Forge:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name domain.com;
root /home/forge/domain.com/public;
...
}
This occurs because nginx searches for a configuration block containing default_server when no matching domain can be found. You can remove the default_server tag for the default(/etc/nginx/enabled-sites/default) and move it the config for the site you want to display by default:
server {
listen 80 default_server;
server_name example.net www.example.net;
...
}
your server block with updated default_server:
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2;
server_name domain.com;
root /home/forge/domain.com/public;
...
}
Be sure to edit the default config to remove the default_server tag before restarting nginx, it is not allowed to have two config blocks with default_server. The config can be verified using nginx -t
more information can be found at the nginx documentation
Why would you want to access your server from the naked ip?
Nginx returns a 404 since it cant find the requested domain on your server.
If you look at your folder structure your project folder corresponds to your site domain. It redirects you towards the right folder based on your domain name.
You could make a default project to show you something like phpinfo() when request trough the ip

Getting subdomains to work locally with Laravel

I am having a hard time getting subdomains to work locally. I have Docker serving the application to port 8080, and I am able to see the Laravel welcome screen. I then have a simple route setup like this:
Route::domain('{name}.localhost:8087')->group(function () {
return 'Hello World';acrylic dns
});
I am using Laravel's basic server, i.e. php artisan serve --host=0.0.0.0 --port=8087
When I try and view the page, nothing happens. It just goes to the welcome screen. I have even tried adding 'test.localhost' to the /etc/hosts file. Couple questions:
1) Can you have the port in the host like I have it there (in the Laravel route)?
2) I have seem somewhat similar posts where the solution was to use acrylic dns (on windows). I am using a Mac. Is this something where I need an actual DNS server?
3) I am planning on using nginx, do I need a 'beefier' web server to accomplish this?
With the basic Laravel server I have tried hard coding test.localhost in the route, with and without the port. I'm sure I am goofing something up, just not sure where. I am on a Mac, and I am running Laravel 5.6. Thanks in advance!
1) No, the web server configuration will listen on the port.
// nginx
server {
listen 8080;
...
}
2) You add the subdomains in your /etc/hosts file and create separate nginx configurations:
// /etc/hosts
subdomain1.foo.localhost 127.0.0.1
subdomain2.foo.localhost 127.0.0.1
subdomain3.foo.localhost 127.0.0.1
// nginx subdomain1.foo.localhost.conf
server {
listen 8080;
server_name subdomain1.foo.localhost;
...
}
// nginx subdomain2.foo.localhost.conf
server {
# set different port if needed
# listen 8082
listen 8080;
server_name subdomain2.foo.localhost;
...
}
// nginx subdomain3.foo.localhost.conf
server {
# set different port if needed
# listen 8083
listen 8080;
server_name subdomain3.foo.localhost;
...
}
3) Nginx is a production ready web server, you may need load balancers and multiple instances of the web servers to scale out, but nginx will be more than sufficient.
If you're using Artisan serve, go to
/etc/hosts (or similar)
127.0.0.1 subdomain.localhost
And open in the browser
subdomain.localhost:8087

Vagrant Refused via browser

I am very new to using Vagrant in my development workflow, however when setting up the box using vagrant up and then accessing it via my host i get a connection refused with my browser.
Is all that needs to be done to work is:
vagrant init scotch/box
vagrant up
?
Make sure to forward the 80 port from the guest so you can access the vm from your browser. Edit your Vagrantfile and make sure to have a line like (by default when doing vagrant init I believe this is commented)
config.vm.network "forwarded_port", guest: 80, host: 8080
You can then access your web server (if running on the VM) from http://127.0.0.1:8080 or http://localhost:8080
If you prefer to use a fixed private IP, you will need to add
config.vm.network :private_network, ip: "192.168.33.10"
you will then access the vm server using http://192.168.33.10
note:
if you have nothing running on the port 80 nothing will be displayed (obviously). you can run sudo netstat -ant and check you have a process running on port 80
Adjust the port number from the example with the service you're running if it runs on another port.
By default, you get a NAT interface that you cannot connect into. You should define a private network in vagrant to make incoming connections available. Then, also check your VM's firewall settings.
I had a similar problem and just wanted to share my solution, maybe it helps someone else. I couldnt reach the localhost:8080 via browser. The connection got interrupted everytime.
After a long wasted time and search, I found my problem, it was due to the nginx.conf file.
#nginx config file
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
listen localhost;
root /usr/share/nginx/html;
index index.html index.htm;
server_name localhost;
location \ {
try_files $uri $uri/ = 404;
}
}
i forgot the backslash after location....
after adding it, i could restart my nginx via vagrant ssh and now it's working again
best
totem
There are some provider-related issues when it comes to networking, especially with Hyper-V, that the get-started docs don't mention. See https://developer.hashicorp.com/vagrant/docs/providers/hyperv/limitations

Resources