You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/golang-on-azure/baseline-testing.md
+25-28Lines changed: 25 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,27 +7,26 @@ layout: learningpathall
7
7
---
8
8
9
9
10
-
### Baseline testing of Golang Web Page on Azure Arm64
11
-
This section demonstrates how to test your Go installation on the **Ubuntu Pro 24.04 LTS Arm64** virtual machine by creating and running a simple Go web server that serves a styled HTML page.
10
+
### Baseline Testing: Running a Go Web Server on Azure Arm64
11
+
To validate your Go toolchain and runtime environment, you can build and run a lightweight web server. This ensures that compilation, networking, and runtime execution are working correctly on your Ubuntu Pro 24.04 LTS Arm64 virtual machine running on Azure Cobalt 100.
12
12
13
-
**1. Create Project Directory**
14
-
15
-
First, create a new folder called goweb to contain all project files, and then navigate into it:
13
+
1. Create the project directory
14
+
15
+
Start by creating a new folder to hold your Go web project and navigate to it:
16
16
17
17
```console
18
18
mkdir goweb && cd goweb
19
19
```
20
-
This command creates a new directory named goweb and then switches into it.
21
20
22
-
**2. Create HTML Page with Bootstrap Styling**
21
+
2. Create an HTML Page with Bootstrap Styling
23
22
24
-
Next, create a file named `index.html` using the nano editor:
23
+
Next, create a simple web page that your Go server will serve. Using the nano editor (or any editor of your choice), create a file named `index.html`:
25
24
26
25
```console
27
26
nano index.html
28
27
```
29
28
30
-
Paste the following HTML code into the index.html file. This builds a simple, styled web page with a header, a welcome message, and a button using Bootstrap.
29
+
Paste the following HTML code into the `index.html` file. This page uses Bootstrap for styling and includes a header, a welcome message, and a button that links to a Go-powered API endpoint.
31
30
32
31
```html
33
32
<!DOCTYPE html>
@@ -66,14 +65,14 @@ Paste the following HTML code into the index.html file. This builds a simple, st
66
65
</body>
67
66
</html>
68
67
```
69
-
**3. Create Golang Web Server**
68
+
3. Create Golang Web Server
70
69
71
-
Nowcreate the Go program that will serve this web page:
70
+
Now, let’s create the Go program that will serve your static HTML page and expose a simple API endpoint.
72
71
73
72
```console
74
73
nano main.go
75
74
```
76
-
Paste the following code into the main.go file. This sets up a very basic web server that serves files from the current folder, including the **index.html** you just created. When it runs, it will print a message showing the server address.
75
+
Paste the following code into the `main.go` file. This sets up a very basic web server that serves files from the current folder, including the `index.html` you just created. When it runs, it will print a message showing the server address.
77
76
78
77
```go
79
78
package main
@@ -105,56 +104,54 @@ func main() {
105
104
}
106
105
```
107
106
{{% notice Note %}}Running on port 80 requires root privileges. Use sudo with the full Go path if needed.{{% /notice %}}
108
-
**4. Run on the Web Server**
109
107
110
-
Run your Go program with:
108
+
4. Run the Web Server
109
+
110
+
Compile and start your Go program with:
111
111
112
112
```console
113
113
sudo /usr/local/go/bin/go run main.go
114
114
```
115
115
116
-
This compiles and immediately starts the server. If the server starts successfully, you will see the following message in your terminal::
116
+
This command compiles the Go source code into a binary and immediately starts the server on port 80. If the server starts successfully, you will see the following message in your terminal:
117
117
118
118
```output
119
119
2025/08/19 04:35:06 Server running on http://0.0.0.0:80
120
120
```
121
-
**5. Allow HTTP Traffic in Firewall**
121
+
5. Allow HTTP Traffic in Firewall
122
+
123
+
On Ubuntu Pro 24.04 LTS virtual machines, UFW (Uncomplicated Firewall) is used to manage firewall rules. By default, it allows only SSH (port 22), while other inbound connections are blocked.
122
124
123
-
On **Ubuntu Pro 24.04 LTS** virtual machines, **UFW (Uncomplicated Firewall)** is used to manage firewall rules. By default, it allows only SSH (port 22) and blocks most other traffic.
125
+
Even if you have already configured Azure Network Security Group (NSG) rules to allow inbound traffic on port 80, the VM level firewall may still block HTTP requests until explicitly opened.
124
126
125
-
So even if Azure allows HTTP on port 80 (added to inbound ports during VM creation), your VM’s firewall may still block it until you run:
127
+
Run the following commands to allow HTTP traffic on port 80:
126
128
127
129
```console
128
130
sudo ufw allow 80/tcp
129
131
sudo ufw enable
130
132
```
131
-
You can verify that HTTP is now allowed with:
133
+
After enabling UFW and allowing traffic on port 80, confirm that the firewall is now configured correctly by running:
132
134
133
135
```console
134
136
sudo ufw status
135
137
```
136
-
You should see an output similar to:
138
+
You should see output similar to:
137
139
```output
138
140
Status: active
139
141
140
142
To Action From
141
143
-- ------ ----
142
-
8080/tcp ALLOW Anywhere
143
144
80/tcp ALLOW Anywhere
144
-
8080/tcp (v6) ALLOW Anywhere (v6)
145
145
80/tcp (v6) ALLOW Anywhere (v6)
146
146
```
147
147
148
-
**6. Open in Browser**
149
-
150
-
Run the following command to print your VM’s public URL, then open it in a browser:
148
+
6. Open in a Browser
149
+
To quickly get your VM’s public IP address and form the URL, run:
151
150
152
151
```console
153
152
echo "http://$(curl -s ifconfig.me)/"
154
153
```
155
-
When you visit this link, you should see the styled HTML page being served directly by your Go application.
156
-
157
-
You should see the Golang web page confirming a successful installation of Golang.
154
+
Open this URL in your browser, and you should see the styled HTML landing page being served directly by your Go application.
0 commit comments