So I do have this code written in go
:
// firstserver - my first server
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", Handler)
err := http.ListenAndServe(":80", nil)
if err != nil {
log.Fatal(err)
}
}
// Handler - a handler function for a normal enter
func Handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "You're connected")
}
Now, when I go to my browser and type localhost:80
(or just localhost
), the page loads, and I see the message You're connected
. Now I wanted to try to connect from other devices too. So I took my other laptop. I checked my adapter address, its 192.168.0.15
. So when I typed 192.168.0.15:80
on the other laptop, it worked again, cool!
Primarly I am trying to do some simple server to use it on my phone when I am at college, check the schedules, have some notes, etc. I took my smartphone, I disconnected from my WiFi, switched to my smartphones internet and dumbly typed 192.168.0.15:80
again. I knew it wouldn't work, cuz it's not my external IP. And it didn't.
So I looked up the IP address that my ISP provider gives me, it looks like this: 88.156.xxx.xx
. Now on my phone I typed 88.156.xxx.xx:80
and it didn't work. I tried to search SO and other resources on the web on how to connect remotely to my server from outside of LAN. And I didn't find an answer. Is there a way to do that without, I don't know, paying for sorts of things, or something like this?
P.S I'm living in a rented room, there's not only me in the house, so I don't have a way to configure a router (manually or over the web)