- Served at path
/helloworld/node/
- Created by
express js
GET
API- Routed at
/helloworld/node/
- Returns a
text/plain
response containing Hello World!!
-
POST
API -
Routed at
/helloworld/node/adder
-
Request body example:
POST /helloworld/node/adder application/json { "a": 523, "b": 10 }
-
JSON
response body example:200 OK application/json { "sha256": "fb8a0d2da8683cec6cc64542f95ae11e085c72d56c744b2be5be335295976610" }
-
GET
API -
Routed at
/helloworld/node/write
-
request example:
GET /helloworld/node/write?line=40
-
response example:
200 OK text/plain Line 40 : This is just a sample text
-
Systemd service configuration is available at
/os/helloworld-node.service
-
In the mentioned file, change
<path/to/nodejs/main/file>
to absolute path ofindes.js
file -
Save the service file at
/lib/systemd/system/helloworld-node.service
-
Enable the service:
> sudo systemctl enable helloworld-node
-
start the service:
> sudo systemctl start helloworld-node
-
Now, the server is listening on
0.0.0.0:3000
-
Add proxy config to Nginx server as bellow:
location /helloworld/node { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://localhost:3000; }
-
Restart Nginx service:
> sudo systemctl restart nginx
- Full Nginx config is available at
/nginx/nginx-server-config