I'm trying to get ngrok's dynamically generated IP address programmatically by using bash to set globals and env variables.
Below is what I have so far.
Run ngrok http {server url}
Inside your host root directory run:
curl http://localhost:4040/api/tunnels > ~/ngrok_tunnels.json;
Install jq
Brew install [jq](https://stedolan.github.io/jq/) (let's you access json through bash)
Afterwards you just need to access this json following jq's docs.
Inside the project root that is calling the dev URL. [0]=(http) [1]=(https)
echo “NGROK_TUNNEL=$(jq .tunnels[1].public_url ~/ngrok_tunnels.json
)" >> .env
Set all of your dev urls to process.env.NGROK_TUNNEL
So this works, but is it the "best way" to do this?
For people who want to get a url through ngrok using python there is the pyngrok library
from pyngrok import ngrok
#Open a HTTP tunnel on the default port 80
#<NgrokTunnel: "http://<public_sub>.ngrok.io" -> "http://localhost:80">
http_tunnel = ngrok.connect()
#Open a SSH tunnel
#<NgrokTunnel: "tcp://0.tcp.ngrok.io:12345" -> "localhost:22">
ssh_tunnel = ngrok.connect(22, "tcp")
it is also possible to do some things directly via the ngrok API. I didn't find the option to create a tunnel, but having a tunnel created you can restart it or update it
https://ngrok.com/docs/api#api-tunnel-sessions-list
The short answer is yes.
You can upgrade to a paid plan and use the --subdomain argument to get the same ngrok url every time. The next price level from that includes white labeling where you can use your own custom domain as well.
Related
I'm trying to run a collection from a free webhosting text files and I can run it easily with:
newman run %https://mysite.txt%
Now I'm trying to locally capture the sent requests from the newman run so I'm adding this command in CMD:
set HTTP_PROXY=127.0.0.1:62248
this should allow my app to record requests from Newman when using it like that:
newman run %https://mysite.txt% --env-var HTTP_PROXY --insecure
(it works perfect on local hosted files)
However since the txt file is hosted by https protocol, I'm getting the following error:
error: collection could not be loaded
unable to fetch data from url "https://mysite.txt"
tunneling socket could not be established, cause=getaddrinfo ENOTFOUND 62248
Can I run Newman collection from a secure https web address while locally recording it, or should I download and save it first locally and then run it locally?
My current temporary(hopefully I'll get a better one), is to download the file from wherever it's being stored, and run Newman locally with the downloaded file.
I'm trying to install ngrok on my mac. Here is what I have done so far.
Downloaded ngrok from here https://ngrok.com/download.
Unziped the file and copied the Unix Executable File into /usr/local/bin like many other questions and answers suggested.
Now when I try to execute any command with ngrok in the current folder or in the project one the result of this is command not found but ngrok is there as you can see.
By the way, here is the path:
ramonmorcillo#Ramons-MacBook-Pro bin % echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin
I may be missing something but I have been all morning searching for an answer and followed all other questions steps but it is still not working. Can anyone help me solve this?
I finally solved it. I connected my account and it worked.
ramonmorcillo#Ramons-MacBook-Pro bin % ./ngrok authtoken MY _AUTH_TOKEN
Authtoken saved to configuration file: /Users/ramonmorcillo/.ngrok2/ngrok.yml
ramonmorcillo#Ramons-MacBook-Pro bin % ./ngrok help
NAME:
ngrok - tunnel local ports to public URLs and inspect traffic
DESCRIPTION:
ngrok exposes local networked services behinds NATs and firewalls to the
public internet over a secure tunnel. Share local websites, build/test
webhook consumers and self-host personal services.
...
I know that if I want to use a proxy with wget, I have to edit /etc/wgetrc or ~/.wgetrc file and set there the proxy address and port.
What I want to know if is there any option to use wget and use a proxy BUT without editing any config file.
That's all. Thanks.
You can pass the proxy settings via the environment, e.g.:
https_proxy=http://proxy.example.com:3128 wget http://www.example.com
I want to deploy my local larvel website online with NGROK.
I'm using Laragon with Apache server, I use this command :
ngrok http -host-header=rewrite site.dev:80
It almost work, but the asset file (like CSS/Image) are still link to my local server (site.dev). And it's the same for my link, the laravel routing command :
{{ route('ngo') }} return site.dev/ngo instead of my online tunnel (http://number.ngrok.io/ngo)
I've try to :
Edit the http.conf (https://forum.laragon.org/topic/88/allow-outside-other-devices-phones-tablets-to-access-your-local-server-using-ngrok)
Change my Laravel App url in config/app.php
Change my url in .env file
Nothings work
I ran into this problem myself just now, but also found a way to fix it:
Run the ngrok command without the -host-header=rewrite part, resulting in
ngrok http site.dev:80
After this, edit your http.conf file and add the ngrok domain as a server alias. For example:
ServerAlias nd3428do.ngrok.io
The problem is that Laravel's route helper uses the HOST header, which is rewritten to site.dev. Without the -host-header part, the header isn't rewritten and now it works.
I'm new to generating certificates and using letsencrypt, so I'm not sure if this is a dumb question or even possible.
I want to create a small example webapplication using node.js. And I want to test how to implement https, and how to get a proper certificate.
So I tried to use letsencrypt. But it doesn't seem to work.
I'm using my local machine (win10) and I'm cloning the git. Afterwards I try to execute the command ./letsencrypt-auto but windows won't recognize the script as a command.
How is it possible to use letsencrypt locally on my win10 machine, where no webserver (usually) is running.
letsencrypt-auto only works with Apache on Debian-based OSes (for now). There's no way to use it on Windows, yet.
That said, people are trying. You might find this project interesting. (Disclaimer: I have no affiliation with that and haven't tried it myself.)
Alternatively you can look at - https://github.com/minio/concert built using golang, you can get a windows binary quite naturally.
Install
You need to have golang installed to compile concert.
$ go get -u github.com/minio/concert
How to run?
Generates certs in certs directory by default.
$ sudo concert gen <EMAIL> <DOMAIN>
Generate certificates in custom directory.
$ sudo concert gen --dir my-certs-dir <EMAIL> <DOMAIN>
Renew certificates in certs directory by default.
$ sudo concert renew <EMAIL>
Generate certificates in custom directory.
$ sudo concert renew --dir my-certs-dir <EMAIL>
Run a server with automatic renewal.
$ sudo concert server <EMAIL> <DOMAIN>
Alternatively, you can use ngrok to expose your local port 80 and make it available to the world via the secure tunnel on subdomain.ngrok.io. There is also a possibility to pass that domain as a CNAME for your own domain name.
All you have to do is:
Create free account with https://ngrok.com/ It works on all operating systems.
Run ngrok http 80 and note your subdomain.ngrok.io
Add the above subdomain to your /etc/hosts as 127.0.0.1 subdomain.ngrok.io. This way you will be able to access that domain locally with SSL, while ngrok will make sure Let's Encrypt is able to access it via the Internet.
Edit: Note that this method might not work reliably. Let's encrypt has 20 certificates rate limit per registered domain. Which means up 20 certificates in total can be generated for all ngrok users per week.
Disclaimer: I have no affiliation with ngrok.io.