Skip to content

How to Deploy a Web Application on VPS

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.

  • Point the application’s A record to your VPS public IPv4 (and AAAA only 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.
Terminal window
sudo apt update && sudo apt upgrade -y
sudo ss -ltnp
free -h
df -h

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.

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.

  • 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 .env and 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.
Terminal window
curl -I https://app.example.com/
sudo systemctl --failed
sudo journalctl -u YOUR_SERVICE -n 50 --no-pager

Create 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.

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.