March 23, 2022

A web service deployed on Raspberry Pi based on Nginx

Prepare the Raspberry Pi

  1. install the Raspberry Pi os into the microSD card, setup the username/password before write into card
  2. power on the Pi and plug in the network cable
  3. get the ip address of the Pi through the router admin page
  4. on another machine ssh into the Pi

  1. enable tcp forwarding for ssh(if you want to use vscode to remote work on it)

Write a service using express and nodeJS

  1. prepare the work space

  1. write the welcome service

  1. run the service and we should be able to see the welcome page on any machine's browser using the ip address

Replace the Nodejs server with the Nginx server

  1. install Nginx

  1. set up the reverse proxy, by enabling the reverse proxy, we added a layer between nodeJS server and the client side to realize the load balance

  1. now if we use any browser under the same wifi network to access the ip address, we can see the welcome page. All the request going to the ip will be handled by Nginx and be sent to localhost:5000 then.

© 2023, Built with Gatsby  
copyright