How to Deploy a Web Application on VPS
A production-ready deployment plan
Section titled “A production-ready deployment plan”Putting an app online involves more than starting a process. This guide covers a reliable baseline for a self-managed Ubuntu 24.04 VPS hosting a Python, Node.js or similar HTTP application.
1. Prepare DNS and server access
Section titled “1. Prepare DNS and server access”- Point the application’s
Arecord to your VPS public IPv4 (andAAAAonly if IPv6 is configured). - Create a separate application user; use SSH keys and disable unnecessary password login only after confirming key access.
- Keep the OS updated and confirm adequate disk, RAM and CPU for the expected workload.
sudo apt update && sudo apt upgrade -ysudo ss -ltnpfree -hdf -h2. Run the app only on localhost
Section titled “2. Run the app only on localhost”Run your application on 127.0.0.1:8000 under systemd or in a container with the port mapped to localhost. Do not expose an unauthenticated development server directly to the public internet.
For Python and Node.js examples, follow our Python/Node.js VPS walkthrough. For a containerized approach, start with Docker on Ubuntu VPS.
3. Configure an Nginx reverse proxy
Section titled “3. Configure an Nginx reverse proxy”server { listen 80; server_name app.example.com;
location / { proxy_pass http://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_read_timeout 60s; }}Enable the Nginx configuration and test sudo nginx -t; then reload. Use Certbot or your provider’s supported ACME method to configure valid HTTPS certificates. Set HTTP-to-HTTPS redirection once TLS works.
4. Apply baseline security
Section titled “4. Apply baseline security”- Allow only SSH, HTTPS and HTTP (for the ACME challenge/redirect) in your firewall, according to your actual setup.
- Keep secrets outside the document root and repository. Restrict permissions on
.envand environment files. - Run apps as non-root and apply dependency updates.
- Add authentication and rate limiting for admin/API endpoints.
- Enable application-level logging, but never log passwords or tokens.
5. Monitoring and rollback
Section titled “5. Monitoring and rollback”curl -I https://app.example.com/sudo systemctl --failedsudo journalctl -u YOUR_SERVICE -n 50 --no-pagerCreate an HTTP health check (e.g. /health) and monitor uptime, CPU, memory, certificate expiration and disk space. Back up both code/config and persistent data, then test restoration. Deploy changes with a clear rollback strategy; do not modify a live database without a backup.
6. SEO considerations for public sites
Section titled “6. SEO considerations for public sites”Serve canonical URLs and a sitemap for public, indexable pages. Make sure assets return 200 and your WAF does not inadvertently challenge verified crawlers. Internal admin/API routes generally should not be indexed.
Next: Compare VPS plans based on app memory and traffic requirements.
Need a VPS for this project? Compare ProstoHosting VPS plans.