We have already talked a lot about Ngrok, now it's time to share the instructions for creating a tunnel. This is an important feature that you may need while working with the software, which will make life much easier. Let's figure out how it can be done.
To create a local HTTP port from the outside, use the http command. To do this, you just need to specify the port as a parameter, for example, for port 80:
$ ngrok http 80
As soon as the tunnel starts working, information about its status will appear in the terminal. In the Forwarding field, it will not be difficult to detect the URL, It is through this URL that you will be able to access the service. During the first launch, Ngrok will warn that this resource is available via Ngrok.
All you have to do is click Visit Site.
Then the server and the content of the site will be available:
To allow other users to log in, you should add HTTP authorization. There is the following option that allows you to do this --basic-auth:
ngrok http --basic-auth="user:password" 80
After that, you will need to enter a password to access the site. If you need to specify a Host for your local site, you can do this using the --host-header option. For example, to replace the domain with example.local, use the following command:
ngrok http --host-header="example.local" 80
By default, the service will be accessible from the outside via HTTPS. If you want it to be accessible only via HTTP, use the --scheme option. For example:
ngrok http --scheme="http" 80
If you want to make a port available on another machine, specify its IP address along with the port. For example, for 192.168.1.143:
ngrok http 192.168.1.143:80
We've figured out how to create a tunnel, now you know even more about Ngrok!