Skip to main content

3 - Web Server (Nginx)

Another way to deploy an SPA is by managing your own server (usually a VPS or VM) and using Nginx to serve the application. This approach gives you maximum control but requires more operational work compared to PaaS or object storage.

Examples of providers: DigitalOcean, Linode, Hetzner, AWS EC2, Google Compute Engine, Azure VM


Platform Highlights​

Full control over configuration
You decide how caching, headers, compression, redirects, and security are handled, with no limitations from external platforms.

Proven and reliable web server
Nginx is lightweight, stable, and optimized for serving static content such as SPA builds.

Customizable routing
You can set up SPA history fallback, API reverse proxies, maintenance pages, and other advanced rules.

Bring your own TLS and domain
Use Let’s Encrypt or your own certificates and configure DNS records directly with your registrar or DNS provider.


Typical Workflow​

  1. Provision a server on a cloud provider or your own hardware.
  2. Install Nginx and (optionally) Certbot for HTTPS certificates.
  3. Build your SPA (npm run build) and copy the generated files to the server.
  4. Configure Nginx to:
    • Serve static files (JS, CSS, images).
    • Redirect HTTP β†’ HTTPS.
    • Add history fallback so all unknown routes return index.html.
    • Apply caching rules (long TTL for assets, short TTL for HTML).
  5. Update DNS so your domain points to the server’s IP address.
  6. Deploy updates by replacing the build files and reloading Nginx.

βœ… Pros​

  • Maximum flexibility and customization.
  • Can serve multiple apps and APIs from one server.
  • Works without depending on a specific vendor.

❌ Cons​

  • Requires ongoing maintenance (security patches, monitoring, scaling).
  • No global CDN by default, which can mean higher latency for distant users.
  • More complex setup compared to PaaS or storage + CDN.

🎯 When to Use​

  • You need custom server logic or integration with other services.
  • You already manage infrastructure and want full control.
  • You prefer to avoid vendor lock-in and manage everything yourself.