March 23, 2022
A web service deployed on Raspberry Pi based on Nginx
Prepare the Raspberry Pi
- install the Raspberry Pi os into the microSD card, setup the username/password before write into card
- power on the Pi and plug in the network cable
- get the ip address of the Pi through the router admin page
- on another machine ssh into the Pi
- enable tcp forwarding for ssh(if you want to use vscode to remote work on it)
Write a service using express and nodeJS
- prepare the work space
- write the welcome service
- 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
- install Nginx
- 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
- 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