简体   繁体   中英

How to access the web server which is installed on Google colab through my local computer browser without using SSH or ngrok

I wanted to create a web server that runs on Google colab. Also I should be able to access it through my browser without using any third party services or SSH. I installed lamp server and tried the port forwarding using socat but for some reason it doesn't work. I also tried Iptables but it seems like that it's unsupported by Google colab at the kernel level. So It would be great if someone could tell me how to do this correctly using socat.

I have installed lamp server on Google colab and I started it using the following commands

!sudo service mysql start
!sudo service apache2 start

And if I use curl to access it through the colab itself it works just as normal.

!curl http://localhost/.

But I wanted to be able to access it via my local computer browser just by typing it's IP address. I retrieved the IP address using the following command.

!curl ipecho.com/plain

I tried port forwarding using iptables but it didn't work.So I tried to port forward using socat with the following command.

!socat TCP4-LISTEN:35.201.184.86,fork TCP:http://localhost:80

(35.201.184.86 was the colab's private IP address at that moment.) But when I try to connect to it with my browser by typing 35.201.184.86 it doesn't work.

So I was wondering if someone could help me with this issue. Maybe I'm using the socat incorrectly. I know that there are ways to do this using SSH and ngrok but I don't want to use SSH or ngrok in this case. Thanks in advance.

Socats TCP address takes IP addresses, not URLs, so try:

socat TCP4-LISTEN:35.201.184.86,reuseaddr,fork TCP:localhost:80

(reuseaddr is just helpful...)

If that does not help you are invited to provide error message or what.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM