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.
It seems like the Google colab's docker systems are under a NAT. That's why I can't connect to the web server by directly typing the IP address.
And the socat works just fine. It forward the traffic from one port to another. The reason I thought it wasn't working is that I couldn't connect to the web server with the IP address. But if I try to connect to the socat port locally with curl it works. So I had no other option but to use a reverse tunneling program. So currently I use localtunnel and it works as expected.
Thanks to @dest-unreach for helping me.