Skip to content

Commit b14cac2

Browse files
switched sample http server to invoke with privs and listen in port 80
1 parent 9ff5570 commit b14cac2

2 files changed

Lines changed: 14 additions & 21 deletions

File tree

content/learning-paths/servers-and-cloud-computing/node-js-gcp/baseline.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,36 +43,28 @@ const server = http.createServer((req, res) => {
4343
res.end('Baseline test successful!\n');
4444
});
4545

46-
server.listen(3000, '0.0.0.0', () => {
47-
console.log('Server running at http://0.0.0.0:3000/');
46+
server.listen(80, '0.0.0.0', () => {
47+
console.log('Server running at http://0.0.0.0:80/');
4848
});
4949
```
50-
- This server listens on port 3000.
50+
- This server listens on port 80.
5151
- Binding to 0.0.0.0 allows connections from any IP, not just localhost.
5252

5353
Run the server in the background:
5454

5555
```console
56-
node app.js &
56+
export MY_NODE=`which node`
57+
sudo ${MY_NODE} app.js &
5758
```
5859
You should see an output similar to:
5960

6061
```output
61-
Server running at http://0.0.0.0:3000/
62+
Server running at http://0.0.0.0:80/
6263
```
63-
{{% notice Note %}}
64-
Make sure your GCP firewall allows TCP traffic on port 3000. On SUSE Arm64, internal firewalls are usually disabled, so only the GCP firewall needs to be configured.
65-
66-
```console
67-
sudo zypper install -y firewalld
68-
sudo firewall-cmd --permanent --add-port=3000/tcp
69-
sudo firewall-cmd --reload
70-
```
71-
{{% /notice %}}
7264
#### Test Locally with Curl
7365

7466
```console
75-
curl http://localhost:3000
67+
curl http://localhost:80
7668
```
7769

7870
You should see an output similar to:
@@ -85,7 +77,7 @@ Baseline test successful!
8577
Also, you can access it from the browser with your VM's public IP. Run the following command to print your VM’s public URL, then open it in a browser:
8678

8779
```console
88-
echo "http://$(curl -s ifconfig.me):3000/"
80+
echo "http://$(curl -s ifconfig.me):80/"
8981
```
9082

9183
You should see the following message in your browser, confirming that your Node.js HTTP server is running successfully:

content/learning-paths/servers-and-cloud-computing/node-js-gcp/benchmarking.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,28 @@ npm install -g autocannon
2121

2222
If your sample HTTP server is not already running from the last section, you can start it by typing:
2323
```console
24-
node app.js &
24+
export MY_NODE=`which node`
25+
sudo ${MY_NODE} app.js &
2526
```
2627

27-
Server should be listening on port 3000 in the background:
28+
Server should be listening on port 80 in the background:
2829

2930
```output
30-
Server running at http://0.0.0.0:3000/
31+
Server running at http://0.0.0.0:80/
3132
```
3233

3334
### Run a Basic Benchmark (Local)
3435

3536
```console
36-
autocannon -c 100 -d 10 http://localhost:3000
37+
autocannon -c 100 -d 10 http://localhost:80
3738
```
3839
- `-c 100` → 100 concurrent connections
3940
- `-d 10` → duration 10 seconds
4041
- URL → endpoint to test
4142

4243
You should see an output similar to:
4344
```output
44-
Running 10s test @ http://localhost:3000
45+
Running 10s test @ http://localhost:80
4546
100 connections
4647
4748

0 commit comments

Comments
 (0)