Skip to main content
Servers Are Up
Virtual Datacenter
PricingFree Tools
Sign inBrowse catalog
Servers Are Up
Virtual Datacenter
PricingFree Tools
Sign inBrowse catalog

Loading…

Servers Are Up

Your apps, automation and data on hardware we own. Build a private stack with predictable capacity and access through your dashboard, API or SSH.

SLA with service creditsOwned hardwareUS-based

Make room for your next idea

Explore the capacity, apps and access options that fit your workload. Check current availability and your total before you buy.

Sign up freeView Pricing

Products

  • Linux VPS
  • Windows VPS
  • Cloud & SaaS Services
  • Cloud Storage (Azure)
  • Virtual Datacenter
  • AI & Agent Hosting
  • Containers
  • Instant Apps
  • Software Platforms
  • Network builder
  • Game Servers
  • Pricing

Resources

  • Free Network Tools
  • 2026 Pricing Benchmark
  • Live SVG Badges
  • Latency & Speed Test
  • Guides & Tutorials
  • Documentation
  • API Reference
  • MCP Server
  • CLI & SDKs
  • OpenAPI & llms.txt
  • Use Cases
  • Free Migration
  • Uptime & Reliability
  • Datacenter
  • System Status
  • Network
  • Provider Comparisons Hub
  • Compare Providers

Company

  • About Us
  • Enterprise
  • Security Architecture
  • Trust Center
  • Blog
  • FAQ
  • Compliance
  • Startup Program
  • Open-Source Sponsorship
  • Press & Media Kit
  • Referral Program
  • Help Center
  • Contact Us
© Servers Are Up
TermsPrivacySLARefund PolicyDPAAcceptable Use
Service information
Docs
  • Documentation Hub
  • Choose a Product
    VMs, Containers & Cloud
  • First Linux Server
    SSH, Firewall & Apps
  • Windows Server 2025
    BYOL & Remote Desktop
  • Remote Access
  • Troubleshooting
  • FAQ
  • All Product Guides
    29 Step-by-Step Guides
  • Cloud & SaaS Catalog
    112 Cloud & SaaS Offerings
  • Azure Cloud Storage
    Hot/Cool/Archive & WORM
  • Resource Manager & RBAC
    Groups, Tags & Locks
  • Multi-Model Cloud DB
    JSONB, SQL & pgvector
  • Cloud Identity & ZTNA
    OIDC, SCIM & PIM
  • Key Vault & KMS
    Secrets & Envelope Keys
  • Cloud SIEM, SOAR & DLP
    Posture & Threat Response
  • API Gateway & Cloud DNS
    Edge WAF & DNS Zones
  • Serverless, Workflows & IoT
    Functions, Queues & DAGs
  • SaaS, Governance & Vault
    Budgets & Off-Host GRS
  • Build Web Apps with AI
  • Next.js and React
  • TypeScript and Node.js
  • npm and Tooling
  • Data and APIs
  • Deploy and Operate
  • Tutorials
  • Infrastructure
  • Automation & Regions
  • API Overview
  • API v1 Reference
    Endpoints & 23 Scopes
  • MCP Server
    129 AI Agent Tools
  • Swagger / OpenAPI 3.1
  • API Playground
  • Versioning & Sunset
  • API Token Security
    Authentication & Tokens
  • Instances API
    Compute Resources
  • Networking API
    Networks & Ports
  • Storage API Availability
    Volumes & Backups
  • Webhooks & Events
    Event Notifications
  • Rate Limits & Best Practices
    Throttling & Retries
  • sau CLI Reference
    34 Commands (v0.2)
  • Browser Web CLI
  • SDKs
  • Infrastructure as Code
    Terraform & Ansible
  • Code Examples
  • CLI & SDK Guides
  • Security Guides
  • Security at a Glance
  • Zero Trust Architecture
  • Live Trust Center
  • Compliance
Need help?

Loading documentation...

Documentation/products

Deploy a Next.js application on a Servers Are Up Linux server

Build and run a production Next.js App Router application under systemd with Caddy automatic HTTPS and firewall rules on a Linux VPS.

Intermediate
25 min
Updated 2026-11-12

Deploy Ready-to-Run Infrastructure in Seconds

Linux VMs from $6/mo · Pooled Virtual Datacenters from $12/mo · Use code WELCOME20 for 20% off your first order.

Browse ServersView Pricing

Commands checked on 2026-11-12 with Ubuntu 24.04 LTS, Node.js 24 LTS, Next.js 16, Caddy 2.8.

What you will have at the end

Your Next.js application will run as an unprivileged systemd service bound to 127.0.0.1:3000 on your Servers Are Up Linux VPS, fronted by Caddy with automatic Let's Encrypt TLS certificates (HTTPS + HTTP/3), structured journald logs, automatic restart on failure, and perimeter firewall rules permitting only ports 80 and 443.

Before you start

  • A running Ubuntu 24.04 Linux server on Compute > Servers (/dashboard/instances). If you have not created one yet, complete Order your first Linux server and sign in with SSH.
  • A domain or subdomain (for example app.example.com) whose DNS records you can edit, or a zone hosted in Network > Cloud DNS zones (/dashboard/cloud-dns).
  • A Next.js repository using output: 'standalone' in next.config.mjs (recommended for compact, reproducible server deployments).

Steps

1. Point your domain at the server and open HTTP/HTTPS ports

  1. Copy your server's public IPv4 address (for example 203.0.113.25) from Compute > Servers (/dashboard/instances).
  2. In your DNS provider or Network > Cloud DNS zones (/dashboard/cloud-dns), create an A record for app.example.com pointing to 203.0.113.25 with a 300 second TTL.
  3. Open Network > Firewall (/dashboard/network?tab=firewall) and enable inbound TCP 80 (for HTTP-01 ACME verification and HTTPS redirects) and TCP/UDP 443 (for TLS 1.3 and HTTP/3) to your server. Keep port 3000 closed to the public internet.

2. Install Node.js 24 LTS, Caddy, and create a dedicated app user

Sign in to your server over SSH or the browser console and install Node.js 24 LTS alongside the official Caddy package:

sudo apt-get update && sudo apt-get install -y ca-certificates curl gnupg git debian-keyring debian-archive-keyring apt-transport-https
curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt-get update && sudo apt-get install -y nodejs caddy

sudo useradd --system --create-home --home-dir /srv/nextjs --shell /usr/sbin/nologin nextapp

3. Clone, configure environment secrets, and build the standalone bundle

Deploy your application files into /srv/nextjs/app and store runtime environment variables in a root-owned /etc/nextjs/app.env file readable only by nextapp:

sudo install -d -m 0750 -o root -g nextapp /etc/nextjs
sudo tee /etc/nextjs/app.env > /dev/null <<'EOF'
NODE_ENV=production
PORT=3000
HOSTNAME=127.0.0.1
NEXT_TELEMETRY_DISABLED=1
APP_URL=https://app.example.com
EOF
sudo chmod 0640 /etc/nextjs/app.env

sudo -u nextapp -s /bin/bash -c '
  git clone https://github.com/your-org/your-nextjs-app.git /srv/nextjs/app
  cd /srv/nextjs/app
  npm ci
  npm run build
  cp -r public .next/standalone/public
  cp -r .next/static .next/standalone/.next/static
'

4. Register and start a hardened systemd unit

Create /etc/systemd/system/nextjs-app.service so systemd supervises the Node.js process, restarts it automatically if it crashes, and isolates the filesystem:

sudo tee /etc/systemd/system/nextjs-app.service > /dev/null <<'EOF'
[Unit]
Description=Next.js Production Server
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=nextapp
Group=nextapp
WorkingDirectory=/srv/nextjs/app/.next/standalone
EnvironmentFile=/etc/nextjs/app.env
ExecStart=/usr/bin/node server.js
Restart=on-failure
RestartSec=3
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ReadWritePaths=/srv/nextjs/app/.next/cache

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now nextjs-app

5. Configure Caddy for automatic HTTPS and compression

Replace /etc/caddy/Caddyfile with a reverse-proxy block for app.example.com that forwards traffic to 127.0.0.1:3000 and adds strict transport headers:

sudo tee /etc/caddy/Caddyfile > /dev/null <<'EOF'
app.example.com {
    encode zstd gzip
    header {
        Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
        X-Content-Type-Options "nosniff"
        Referrer-Policy "strict-origin-when-cross-origin"
        -Server
    }
    reverse_proxy 127.0.0.1:3000 {
        health_uri /api/health
        health_interval 15s
    }
}
EOF

sudo caddy validate --config /etc/caddy/Caddyfile
sudo systemctl reload caddy

Check that it works

Verify both the local loopback listener on the server and the public TLS endpoint from outside:

sudo systemctl status nextjs-app --no-pager
curl -fsSI http://127.0.0.1:3000 | head -n 5
curl -fsSI https://app.example.com | grep -E "HTTP/|strict-transport-security"

You should see HTTP/2 200 alongside the strict-transport-security header, and sudo journalctl -u nextjs-app -n 30 will display clean startup output without errors.

What can go wrong

  • Caddy logs solving challenges: dial tcp ... i/o timeout when issuing the certificate. Either DNS for app.example.com has not propagated to 203.0.113.25 yet (dig +short app.example.com), or inbound TCP port 80 is still closed in Network > Firewall (/dashboard/network?tab=firewall).
  • Static CSS and JS return 404 Not Found in standalone mode. Next.js standalone builds do not copy public/ or .next/static/ automatically; run the two cp -r commands in Step 3 on every release.
  • 502 Bad Gateway from Caddy immediately after deploy. Check sudo journalctl -u nextjs-app -n 50 --no-pager. Usually a required variable in /etc/nextjs/app.env is missing or HOSTNAME was bound to an unreachable interface instead of 127.0.0.1.

Good practice

  • Keep application secrets in Access > Key vault & KMS (/dashboard/key-vault) and render /etc/nextjs/app.env during CI/CD rather than storing secrets in Git or shell history.
  • Build into timestamped release directories (/srv/nextjs/releases/20261112-1) and flip a /srv/nextjs/current symlink before running sudo systemctl restart nextjs-app so rollbacks take less than two seconds.
  • Snapshot the VM on /dashboard/instances before major Node.js or OS upgrades.

Where to go next

  • Run a Next.js app on Ubuntu with systemd
  • Put your own domain on an application and enable HTTPS
  • Store AES-256-GCM secrets and rotate keys in Key Vault

Related Articles

Create a scoped API key and send your first v1 request

Read more

Route APIs with Edge WAF, rate limits and Cloud DNS

Read more

Purchase Azure-backed cloud storage with WORM locks and SAS

Read more

Frequently Asked Questions

What does the Deploy a Next.js application on a Servers Are Up Linux server documentation guide cover?
Build and run a production Next.js App Router application under systemd with Caddy automatic HTTPS and firewall rules on a Linux VPS. It is rated intermediate difficulty (25 min) and applies to Servers Are Up infrastructure and workflows.
Can I manage or automate these steps through the Servers Are Up dashboard, REST API v1, or MCP server?
Yes. Every Servers Are Up server includes browser-based SSH, WebRDP, and VNC console access in the dashboard, plus programmatic control via the REST API v1 (/api/v1) and hosted Model Context Protocol server (/api/mcp/v1) using a scoped Personal Access Token.

Need hands-on help with Deploy a Next.js application on a Servers Are Up Linux server?

Every Servers Are Up virtual machine and container includes an integrated HTML5 browser-based SSH, RDP, and VNC console in your dashboard, default-off inbound firewall rules with per-IP allow-lists, and full programmatic control via REST API v1 and Model Context Protocol (MCP). Explore our Virtual Datacenter Plans or reach out to Servers Are Up Support.

Was this article helpful?

On this page

What you will have at the endBefore you startSteps1. Point your domain at the server and open HTTP/HTTPS ports2. Install Node.js 24 LTS, Caddy, and create a dedicated app user3. Clone, configure environment secrets, and build the standalone bundle4. Register and start a hardened systemd unit5. Configure Caddy for automatic HTTPS and compressionCheck that it worksWhat can go wrongGood practiceWhere to go next