AI

How to host any port to entire internet on any machine?


Banner

In this short blog post, I will explain a great trick to expose various services like Jupyter-notebook, tensorboard, etc. to the entire internet. We generally use it at Nayan

Before following the steps I want you to understand some fundamentals behind the hosting of different services.

Some Basics:

Whenever we host some services on a local server having URLs like (https://localhost:8888 or http://127.0.0.1:8888) they are behind a NAT or firewall of our computer(Most of the hackers work to breach these).

Firewall

To jump over the firewall, we will use ngrok.

Ngrok:

Ngrok allows you to expose a web server running on your local machine to the internet. Just tell ngrok what port your web server is listening on.
something like this:

Ngrok flowchart

Steps to host Jupyter-Notebook on AWS EC2:

  1. First, we need to install tmux for running processes(jupyter in our case) in background and jupyter notebook.

    1
    x
    1
    r

2) Download ngrok using

1
wget [https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip](https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip)

3) Unzip to install ngrok

1
unzip ngrok.zip

4) Create an account on ngrok and get authtoken.

Authtoken

1
./ngrok authtoken <your_auth_token>
  1. Now on tmux we will run jupyter-notebook

    1
    tmux
    1
    jupyter-notebook --ip=0.0.0.0 --allow-root ```
  2. Host the noted port using ngrok. For my case it is 8890

    1
    ./ngrok http 8890

Also, you can make a config file and can host multiple ports using the same account as mentioned here.

  1. Now note the URL you got on ngrok screen.

Ngrok link

  1. Cheers and now hit the URL as many times as you can to access your favorite jupyter notebook.

Conclusion:

In this cool blogpost, we understood to host jupyter notebook on the local machine. We can host other services like tensorboard or anything you want.

p.s. Nayan is a platform that offers high precision services for traffic monitoring and road safety. Check out our website

Share

© 2019 NAYAN All Rights Reserved