Reverse Proxy
Changing Defaults
This configuration will proxy all HTTP requests for localhost port 80 to Endrpi.
Overview#
Nginx can be used as a reverse proxy for Endrpi which provides the following functionality:
- Proxy requests to Endrpi from port 80.
- Serve static content, such as websites, from a directory.
- Route API requests from clients to the Endrpi server.
Prerequisites#
Configuration#
1. Unlink the default Nginx website#
sudo unlink /etc/nginx/sites-enabled/default
2. Copy the default configuration#
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/endrpi
3. Open the Endrpi configuration for editing#
sudo nano /etc/nginx/sites-available/endrpi
4. Change the root location to be used as a proxy pass-through#
location / {
proxy_pass http://localhost:5000;
}
5. Save changes#
Ctrl+O
6. Restart Nginx#
sudo systemctl restart nginx
Requests will now be passed through the proxy: http://localhost/docs .
References#
- Setting up an NGINX web server on a Raspberry Pi®
raspberrypi.org [Last accessed 03/20/2021]