This is the third post for a new graduate. I had the opportunity to use ngrok and found it very convenient, so I will write how to use it. ngrok is a tool that allows you to access the server launched on localhost from the outside. This time I launched localhost with Go and tried to access localhost from my personal smartphone.
After registering as a user from the Official Site, download the zip file and unzip it.
You can use github or google account for user registration.
After unzipping, start ngrok.exe
and type in the command.
ngrok http 8080
If you see the following display, you are done.
You can access localhost: 8080 from the external environment with https://66336728576f.ngrok.io
.
ngrok by @inconshreveable
(Ctrl+C to quit)
Session Status online
Version 2.3.35
Account Account name(Plan: Free)
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://66336728576f.ngrok.io -> http://localhost:8080
Forwarding https://66336728576f.ngrok.io -> http://localhost:8080
Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00
package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "ngrok super convenient")
}
When I accessed https://66336728576f.ngrok.io
from my personal smartphone, ngrok super convenient
was displayed!
ngrok It's convenient.
Recommended Posts