How to Access Golang Web Server App from Internet

Ganesh Velrajan
4 min readJan 30, 2023
Remote Access Local Golang Web App From Internet

Let’s assume you have a Golang web server application that runs in your personal laptop or in a server or in a Raspberry Pi in your office LAN network.

Anyone outside of your office network cannot access the Golang web server application because the application runs in your local network.

Suppose, let’s say, you want to expose the Golang web service app to the internet, so that your customers or remote employees can access the Golang web app from the internet.

Today, there are 3 ways to expose your Golang web server application to the internet.

  1. Deploy the web application in your office server which has a public IP address and domain name.
  2. Deploy the web application in the cloud such as AWS, MS Azure, GCP or web hosting companies like GoDaddy, SiteGround, A2Hosting etc.
  3. Use SocketXP to create a unique public web URL for your Golang web service application.

The first two options above cost more money and more effort in terms of purchasing your own IP address, domain name, configuring and managing them.

To address the above problems and provide an alternate cost-effective solution, we have created SocketXP.

What is SocketXP

SocketXP is a simple, quick and cost-effective way to deploy any web application online in just few seconds.

How it works?

  • Run your Golang web server application in your laptop or any private server in your office LAN network or in a VM in a cloud.
  • Download SocketXP Client and install in the office server or laptop
  • SocketXP Client will create a secure SSL/TLS tunnel from your laptop/server to the SocketXP Cloud Gateway.
  • SocketXP Cloud Gateway will provide a unique public web URL that you can use to access your Golang web service app from the internet.

A Quick Demo:

Let’s use the following simple Golang web application for our demo.

$ cat myapp.go 
package main
import ( "net/http" )

func httpHandler(w http.ResponseWriter, r *http.Request)
{
w.Write([]byte("<h2>Hello World!</h2>"))
}

func main() {
http.HandleFunc("/", httpHandler)
http.ListenAndServe(":3000", nil)
}

Run the myapp.go on a local server or your laptop.

$ go run myapp.go

Using a browser, let’s point to http://localhost:3000 to connect to the Golang web app.

Right now the Golang web service app can be accessed only by you because it runs on your laptop.

Now to make the Golan web application accessible from the internet, let’s download and run the SocketXP Client from the download page.

Next authenticate and register the SocketXP Client with the SocketXP Cloud Gateway, using the auth-token from the Portal Page

Click the copy button to copy the command string and paste it in the terminal window in your laptop or server.

$ socketxp login "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

After registering the SocketXP Client with the SocketXP Cloud Service, you can expose your Golang web server application to the internet by obtaining a unique public web URL as shown in the next section.

Expose Golang web server app to the internet

Use the following command to create a HTTP SSL/TLS tunnel between the Golang web application and the SocketXP Cloud Gateway. This will generate a unique public web URL. Use the SocketXP public web URL to access your Golang web server app from the internet.

$socketxp connect http://localhost:3000 

Public URL ->https://679aa48b-1162-44f7-b6c6-59129dd68b58.socketxp.com

Let’s access the Golang web service app from the internet using the SocketXP Public URL provided in the above output.

You could now share the above link with your customers or remote employees, so that they could access your web application from anywhere in the world.

The above SocketXP public URL is a permanent link just assigned to you and it doesn’t change until you manually delete it from the HTTP tunnels section in the portal.

--

--

Ganesh Velrajan

Ganesh Velrajan is the founder of Ampas Labs Inc. Learn more about our SSH Remote Access Solutions at https://www.socketxp.com and https://www.bastionxp.com