user2167582
user2167582

Reputation: 6378

How to use ngrok to tunnel a port that forwards the traffic to a VM machine hosted locally?

I am able to access my VM's server via ip 12.51.50.142 but I can only ngrok a localhost port. Is there a way I can use ngrok and redirect the traffic to my VM's server? I am on osx, but I figure the tool to do this would be same for mac and linux.

Upvotes: 2

Views: 7550

Answers (2)

deservestarseed
deservestarseed

Reputation: 75

I am running a virtual machine using VMWare, running Ubuntu in said VM (under win 10). This VM runs on local IP 192.168.45.128 and has a webserver running on port 80, which is obviously not internet-accessible. I use ngrok as follows (from win 10, not from within the VM) to get an address which allows me to access this web server from the internet: ngrok http 192.168.45.128:80

you may have to configure VMware's network settings first - there should be an option to use a local IP (like mine, described above) or NAT (which actually did not properly work for me).

You may wanna try: ngrok http 12.51.50.142:80

Hope that helps.

Upvotes: 4

Jan Myszkier
Jan Myszkier

Reputation: 2744

I believe technique called port forwarding is something you're looking for. For a web project, you would have to forward ports 80 and 443 (from your ngrok published machine to your vm). this is something ngrok won't do by itself because there's no way for him to reach your VM alone. The problem is setting this up varies per platform used, so without specifics, I cannot suggest any specific solution. For Linux this is most often achieved with iptables but I saw a lot of other solutions for this purpose.

On OSX, following question should work: https://apple.stackexchange.com/questions/230300/what-is-the-modern-way-to-do-port-forwarding-on-el-capitan-forward-port-80-to

Upvotes: 0

Related Questions