Web Servers
Set Up Nginx Reverse Proxy
Step-by-step set up nginx reverse proxy guide with prerequisites, configuration, verification, troubleshooting, and security tips.
Scope: Commands are examples, not one-click installers. Confirm current upstream documentation and test changes on staging first.
Before you begin
This tutorial is intended for administrators managing a compatible VPS or hosting environment. Requirements: Nginx VPS and a backend app listening on 127.0.0.1:3000. Shared hosting accounts generally do not permit installing system services. Confirm your operating system and package versions before proceeding.
Install
Connect to your server with a non-root account that has the necessary permissions. Review each command before running it; commands below are examples for the stated environment. Replace example.com, usernames, paths and placeholder passwords with your own values.
sudo apt update && sudo apt install nginxConfigure
Configuration is specific to your domain, hosting account, application and security requirements. Never paste placeholder credentials into a production configuration.
sudo nano /etc/nginx/sites-available/example.com
# In server block: location / { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
sudo nginx -t && sudo systemctl reload nginxVerify the result
Run the check below and inspect the output. A successful command is only the first check; also test the service from a browser or a second device where applicable.
curl -I http://example.comTroubleshooting
502: confirm backend listens on 3000 and service is running.
Security and maintenance
Keep backend bound to localhost; configure TLS at proxy.
Next steps
Save a copy of your configuration, document the versions installed, schedule backups where data is involved, and monitor for upstream security updates. For account-specific control-panel instructions, use the WebsiteHost.us support database.