- Served at path
/helloworld/node/ - Created by
express js
GETAPI- Routed at
/helloworld/node/ - Returns a
text/plainresponse containing Hello World!!
-
POSTAPI -
Routed at
/helloworld/node/adder -
Request body example:
POST /helloworld/node/adder application/json { "a": 523, "b": 10 }
-
JSONresponse body example:200 OK application/json { "sha256": "fb8a0d2da8683cec6cc64542f95ae11e085c72d56c744b2be5be335295976610" }
-
GETAPI -
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.jsfile -
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