Fixing 16 Production 502s in Nuxt + Docker: V8 OOM, Nitro Prerender & Single-VPS Blue-Green

During a routine 8-layer production observability audit on inmokang.com, Cloudflare GraphQL telemetry surfaced 16 true origin 502 Bad Gateway errors on the apex domain. There had been no user complaints, no uptime pager alerts, and our synthetic checks were green.

My first instinct was the reflex almost every engineer reaches for on a single-VPS Docker stack: "We shipped four production releases over the past two days—those 16 errors are probably brief restart blips during docker compose up -d."

That assumption was completely wrong.

Correlating Cloudflare GraphQL originResponseStatus events against Nginx proxy error logs and Docker container stdout to the exact second proved that all four production deploys produced 0 HTTP 502s. Every single one of the 16 failures occurred inside a single 5-second runtime window caused by Node.js 20 hitting V8's default cgroup Old Space ceiling at 258 MB inside a 512 MB container.

Pulling on that thread exposed three compounding gaps—and a UX telemetry blind spot worth fixing in the same pass:

  1. V8 cgroup heap starvation: A mem_limit: 512m container silently capped V8 Old Space at ~256 MB, crashing under concurrent cacheStatus: bypass SSR bursts while half the container's RAM went unused.
  2. A Nitro serveStatic prerender blind spot: Prerendered static HTML routes like /about bypassed server/middleware, causing internal operator requests to receive public edge-cache SWR headers.
  3. In-place deployment exposure: Even after fixing OOM crashes, recreating a single container in place still left a structural restart window whenever traffic coincided with a release.
  4. Clarity Dead Clicks (21.4%): Session telemetry from the same audit showed readers repeatedly clicking inline architecture SVGs expecting them to zoom.

This post walks through the exact 3-layer forensic trail, the production fixes for each layer, and the live 218 / 218 HTTP 200 (0 HTTP 502s) cutover verification on a single VPS.


1. Three-Layer Timestamp Forensics: Why All 16 Origin 502s Had Nothing to Do with Deploys

When edge analytics report HTTP 5xx spikes, aggregating by day or even by hour hides the real failure mechanism. To isolate what actually dropped connections, we aligned three independent telemetry layers on strict UTC timestamps:

  1. Edge Layer (Cloudflare GraphQL): Filtered httpRequestsAdaptiveGroups strictly on originResponseStatus >= 500, separating true origin failures from edge-only 5xx noise, while inspecting cacheStatus, client IP, and requested path.
  2. Reverse-Proxy Layer (Nginx Error Logs): Inspected upstream socket error codes—specifically distinguishing 104: Connection reset by peer (an active process dying mid-request) from 111: Connection refused (the listening socket is down during container restart).
  3. Runtime Layer (Docker Container Logs): Checked docker logs --timestamps for Node.js V8 garbage-collection traces, exit codes, and Nitro startup timestamps.

Because we had previously configured strict CF-Connecting-IP real-IP restoration at Nginx—covered in our multi-layer botnet defense guide—Nginx and Cloudflare logs lined up by client IP without being masked behind Cloudflare edge subnets.

1.1. Cross-Layer Event Timeline (Dec 3–5, UTC)

Event Window (UTC)Layer 1: Cloudflare GraphQL (originResponseStatus=502)Layer 2: Nginx Error Log SignalLayer 3: Docker Container Runtime StateRoot Cause Classification
Dec 3–4 (4 Production Deploys)0 errorsNo upstream errors recordedNormal graceful stop and cold start during low-traffic windowsCleared — Not deploy-related
Dec 5 09:38:46Z–09:38:48Z16+ concurrent requests with cacheStatus: bypass from 198.51.100.42Requests forwarded concurrently to upstream :3002V8 Old Space climbs rapidly under concurrent SSR + SQLite readsTraffic burst bypassing edge cache
Dec 5 09:38:48Z5 × HTTP 502recv() failed (104: Connection reset by peer)FATAL ERROR: Reached heap limit → process aborts (exit 134)In-flight requests killed by V8 OOM
Dec 5 09:38:49Z–09:38:53Z11 × HTTP 502connect() failed (111: Connection refused)Docker restart: unless-stopped rebooting Nitro (09:38:48Z → 09:38:55Z, 7s downtime)Socket unavailable during 7s cold restart
Dec 5 09:38:55Z onward0 errorsClean 200 OK responses restoredFresh Nitro worker listening on :3000Self-recovered after restart

The numbers locked together without a single stray error. Every single one of the 16 / 16 origin 502s fell inside a 5-second burst (2026-12-05T09:38:48Z through 09:38:53Z) triggered when a single client (198.51.100.42) fired more than 16 concurrent cacheStatus: bypass SSR requests at once.

The split between 5 × Connection reset by peer (104) and 11 × Connection refused (111) told the exact mechanical story of a process crash: five requests already held open TCP connections to Node.js when V8 aborted the process, and the next eleven requests arrived during the 7-second window (09:38:48Z → 09:38:55Z) while Docker tore down the dead container and booted Nitro back up.

Key Takeaway: Never blame unexplained 502 Bad Gateway errors on "deploy blips" by gut feel. Correlating Cloudflare originResponseStatus >= 500, Nginx 104 vs. 111 socket errors, and container timestamps to the second immediately separates release windows from runtime crashes.


2. Why Node.js 20 Crashes at 258 MB Inside a 512 MB Docker Container

Opening the Docker logs right before 09:38:48Z revealed the smoking gun:

code
<--- Last few GCs --->
[1:0x7f9a001c8000] 48291042 ms: Mark-Compact 251.2 (258.0) -> 250.0 (259.0) MB, 312.4 / 0.0 ms (average mu = 0.089, current mu = 0.012) allocation failure; scavenge might not succeed
[1:0x7f9a001c8000] 48291418 ms: Mark-Compact 251.8 (258.5) -> 250.6 (259.2) MB, 348.1 / 0.0 ms (average mu = 0.081, current mu = 0.008) allocation failure; scavenge might not succeed

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

At first glance, that number looks broken: why did Node.js run out of memory at 258 MB when Docker gave the container mem_limit: 512m?

The answer lives in how Node.js 20 sizes the V8 heap inside Linux cgroups. When --max-old-space-size is omitted, Node.js reads the container's cgroup memory ceiling (512 MB) and applies a conservative ~50% heuristic to cap V8's Old Space around 256 MB. The runtime reserves the remaining half for native allocations, stack frames, and OS page cache.

In steady state, a Nuxt 4 + @nuxt/content v3 server serving cached routes idles comfortably around 110–140 MB of V8 heap. Under a burst of 16+ simultaneous cacheStatus: bypass SSR requests, however, every concurrent request allocates:

  • Vue SSR virtual DOM trees and payload serialization buffers,
  • @nuxt/content v3 SQLite query results and parsed MDC AST nodes,
  • Nitro response streams and head/SEO metadata objects.

Before V8's generational garbage collector can sweep short-lived objects from New Space, concurrent allocations promote into Old Space, slamming directly into the ~256 MB wall. Mark-Compact runs back-to-back cycles reclaiming barely 1.2 MB (251.2 -> 250.0 MB), mutator utilization (mu) collapses to 0.008, and V8 aborts the process—even though ~250 MB of the container's memory budget was never even touched.

2.1. Sizing Cgroup Memory and V8 Old Space Intentionally

Blindly raising --max-old-space-size without raising the container's cgroup limit is dangerous: if V8 heap plus native RSS (libuv, OpenSSL buffers, V8 code space, SQLite page cache) exceeds mem_limit, the Linux kernel OOM killer sends an immediate SIGKILL (exit 137) with zero JavaScript stack trace.

Instead, we tuned all three memory boundaries together in docker-compose.yml:

  • mem_limit: 768m — raises the physical RAM ceiling by 50%.
  • memswap_limit: 1024m — provides a 256 MB emergency swap cushion against transient native RSS spikes so the kernel never abruptly SIGKILLs the container.
  • NODE_OPTIONS=--max-old-space-size=512 — explicitly doubles V8 Old Space headroom (~256 MB → 512 MB) while preserving a deterministic 256 MB physical RAM margin (768 - 512 = 256 MB) for non-V8 native memory.
yaml
services:
  nuxt-app-blue:
    image: ${DOCKER_IMAGE:-web-app:latest}
    container_name: nuxt-app-blue
    restart: unless-stopped
    mem_limit: 768m
    memswap_limit: 1024m
    ports:
      - "127.0.0.1:3002:3000"
    environment:
      - NODE_ENV=production
      - NODE_OPTIONS=--max-old-space-size=512
      - NUXT_PUBLIC_SITE_URL=https://inmokang.com
      - NUXT_SITE_URL=https://inmokang.com
    networks:
      - web-network

2.2. Before vs. After Memory Budget Comparison

ParameterBefore (Incident Baseline)After (Hardened Production)Operational Impact
Docker mem_limit512m768m+256 MB physical RAM ceiling
Docker memswap_limitDefault (uncontrolled / equal)1024m (+256m swap cushion)Absorbs brief native RSS bursts without SIGKILL
V8 Old Space CeilingImplicit cgroup 50% (~256 MB)Explicit 512 MB (--max-old-space-size=512)2.0× JavaScript heap headroom under SSR spikes
Non-V8 Native RSS Margin~256 MB (unused while V8 crashed)256 MB RAM + 256 MB swapBalanced budget for SQLite, libuv, and TLS buffers
Observed Failure ModeMark-Compact 251.2 (258.0) MB → OOM exit 134 + 7s outage0 OOM restarts under concurrent SSR stressEliminates single-client bypass crash vector

Key Takeaway: Never rely on Node.js's implicit cgroup memory heuristic inside small Docker containers. Always pair mem_limit, memswap_limit, and an explicit NODE_OPTIONS=--max-old-space-size so V8 Old Space gets ~65% of container RAM and native RSS keeps a hard 256 MB buffer.


3. Closing the Nitro serveStatic Blind Spot on Prerendered Routes (/about)

Fixing the V8 crash explained the 16 origin 502s, but our 8-layer header audit flagged a second anomaly right beside it.

To keep internal QA sessions and editorial previews out of Cloudflare's edge cache and analytics streams, our Nuxt server evaluates internal traffic via operator IP allowlists (203.0.113.10), an explicit query parameter (?internal_bypass=1), and internal bypass cookies (_ignore_analytics=1, internal_ip_flag=1). When internal traffic is detected, Nitro stamps:

http
Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate
CDN-Cache-Control: no-store
Cloudflare-CDN-Cache-Control: no-store

Meanwhile, public visitors receive edge-friendly Stale-While-Revalidate (SWR) caching:

http
Cache-Control: public, max-age=0, must-revalidate
CDN-Cache-Control: public, s-maxage=300, stale-while-revalidate=3600
Cloudflare-CDN-Cache-Control: public, s-maxage=300, stale-while-revalidate=3600

On every dynamic SSR route (/, /blog/..., /en/blog/...), this worked exactly as designed. Yet when we probed /about—which is configured with routeRules: { '/about': { prerender: true } }—from our internal operator IP (203.0.113.10), Nitro returned CDN-Cache-Control: public, s-maxage=300, stale-while-revalidate=3600 instead of no-store.

3.1. Why prerender: true Bypasses server/middleware

The bug came down to Nitro's request pipeline execution order:

  1. For standard SSR routes, requests enter Nitro → run server/middleware/* (which previously set event.context.isInternalTraffic = true) → execute the Nuxt renderer → run server/plugins/seo-headers.ts (beforeResponse).
  2. For prerender: true routes, Nitro compiles /about/index.html into the static asset bundle at build time. At runtime, Nitro's internal serveStatic handler intercepts the request early and streams the pre-built HTML file directly from disk—completely bypassing server/middleware/*.
  3. When seo-headers.ts ran at header finalization, event.context.isInternalTraffic was still undefined. The plugin treated the internal request as an external public visitor and stamped public SWR cache headers onto the response.

Worse still, Nitro's static/SWR response path can flush 304 Not Modified or call res.writeHead() / res.end() before H3's beforeResponse hook executes, meaning a single beforeResponse hook alone is not airtight.

3.2. Unifying Internal Traffic Detection via Idempotent Utility + Nitro request Hook

We fixed the blind spot permanently in three steps:

  1. Extract an idempotent evaluator (server/utils/internalTraffic.ts): Guard execution with event.context._internalTrafficEvaluated so calling it from multiple lifecycle stages never duplicates cookie mutations or header work.
  2. Hook the earliest Nitro lifecycle entry (request) plus fallback in applyResponseCacheHeaders: Running evaluateInternalTraffic(event) inside nitroApp.hooks.hook('request', ...) guarantees every request—SSR, prerendered serveStatic, or feed route—is classified before static file serving begins. Wrapping res.writeHead and res.end in guardResponseLifecycle(event) guarantees applyResponseCacheHeaders(event) executes before headers hit the wire.
  3. Synchronize Cloudflare Edge Cache Rule Exclusions: Even with airtight origin headers, an edge cache HIT served from a prior public visitor would still mask internal debugging unless the Cloudflare Cache Rule explicitly bypasses internal_bypass=1, _ignore_analytics=1, internal_ip_flag=1, and internal operator IP 203.0.113.10.
ts
// server/utils/internalTraffic.ts (sanitized)
import { type H3Event, getCookie, getRequestHeader, getRequestURL, setCookie, setResponseHeader } from 'h3'

const INTERNAL_EXCLUDED_IPS = new Set<string>(['203.0.113.10'])
const IGNORE_COOKIE = '_ignore_analytics'
const INTERNAL_IP_COOKIE = 'internal_ip_flag'

export function evaluateInternalTraffic(event: H3Event): void {
  if (event.context._internalTrafficEvaluated) return
  event.context._internalTrafficEvaluated = true

  const clientIp = (
    getRequestHeader(event, 'cf-connecting-ip')
    || getRequestHeader(event, 'x-real-ip')
    || getRequestHeader(event, 'x-forwarded-for')
    || ''
  ).split(',')[0]?.trim() || ''

  const url = getRequestURL(event)
  const isExcludedIp = Boolean(clientIp && INTERNAL_EXCLUDED_IPS.has(clientIp))
  const hasIgnoreCookie = getCookie(event, IGNORE_COOKIE) === '1'
  const hasBypassQuery = url.searchParams.get('internal_bypass') === '1'

  event.context.isInternalTraffic = Boolean(
    import.meta.dev || isExcludedIp || hasIgnoreCookie || hasBypassQuery,
  )

  if (isExcludedIp) {
    setCookie(event, INTERNAL_IP_COOKIE, '1', { path: '/', sameSite: 'lax', httpOnly: false })
    event.context.internalIpCookieMutated = true
  }

  if (event.context.isInternalTraffic || event.context.internalIpCookieMutated) {
    setResponseHeader(event, 'Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate')
    setResponseHeader(event, 'CDN-Cache-Control', 'no-store')
    setResponseHeader(event, 'Cloudflare-CDN-Cache-Control', 'no-store')
  }
}

And inside server/plugins/seo-headers.ts, both the Nitro request hook and applyResponseCacheHeaders call evaluateInternalTraffic(event):

ts
// server/plugins/seo-headers.ts (excerpt)
export default defineNitroPlugin((nitroApp) => {
  nitroApp.hooks.hook('request', (event) => {
    evaluateInternalTraffic(event)
    guardResponseLifecycle(event) // intercepts writeHead/end before flush
  })

  nitroApp.hooks.hook('beforeResponse', (event) => {
    applyResponseCacheHeaders(event) // idempotent fallback
  })
})

3.3. Verified Header Behavior Matrix After Refactor

Route TypeVisitor ClassCloudflare Edge Cache RuleOrigin Cache-ControlOrigin CDN-Cache-Control
Dynamic SSR (/blog/...)External PublicEligible for SWR (HIT / STALE)public, max-age=0, must-revalidatepublic, s-maxage=300, stale-while-revalidate=3600
Dynamic SSR (/blog/...)Internal (203.0.113.10 / internal_bypass=1)Bypassed at Edgeprivate, no-cache, no-store, max-age=0, must-revalidateno-store
Prerendered Static (/about)External PublicEligible for SWR (HIT / STALE)public, max-age=0, must-revalidatepublic, s-maxage=300, stale-while-revalidate=3600
Prerendered Static (/about)Internal (203.0.113.10 / _ignore_analytics=1)Bypassed at Edgeprivate, no-cache, no-store, max-age=0, must-revalidateno-store

Zero edge-cache poisoning for external visitors, zero stale cached views or analytics pollution for internal operators—across both SSR and prerender: true routes.


4. Atomic Nginx Blue-Green Cutover on a Single VPS & 218/218 HTTP 200 Proof

Even though our four earlier deploys happened during quiet periods and escaped 502s, relying on luck during in-place docker compose up -d --force-recreate is a ticking clock. The moment a search crawler or high-intent visitor hits the server during the 5–10 second container recreation window, Nginx returns 111: Connection refused (502).

You do not need Kubernetes, Nomad, or an external load balancer to get true zero-downtime Blue-Green cutovers on a single Linux VPS. All it takes is two container slots, an atomic filesystem rename, and a strict pre-cutover verification gate.

4.1. Dual-Slot Architecture & Atomic Upstream Swap

We allocate two symmetric application slots on loopback ports behind the host Nginx reverse proxy:

  • Blue slot: nuxt-app-blue listening on 127.0.0.1:3002
  • Green slot: nuxt-app-green listening on 127.0.0.1:3012

Nginx never hardcodes the active container port inside the main virtual host block. Instead, it includes a dedicated one-line upstream pointer at /srv/reverse-proxy/conf.d/upstream.inc and enables proxy_next_upstream resilience:

nginx
# /srv/reverse-proxy/conf.d/upstream.inc (swapped atomically)
server 127.0.0.1:3012 max_fails=2 fail_timeout=5s;
server 127.0.0.1:3002 backup;
nginx
# /srv/reverse-proxy/sites-enabled/inmokang.conf (excerpt)
upstream nuxt_app_origin {
    include /srv/reverse-proxy/conf.d/upstream.inc;
    keepalive 32;
}

server {
    listen 443 ssl http2;
    server_name inmokang.com;

    location / {
        proxy_pass http://nuxt_app_origin;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header Host $host;
        proxy_set_header CF-Connecting-IP $http_cf_connecting_ip;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_next_upstream error timeout invalid_header http_502 http_503;
        proxy_next_upstream_tries 2;
        proxy_connect_timeout 3s;
        proxy_read_timeout 30s;
    }
}

Every deployment executes a deterministic 5-stage state machine in /srv/apps/web/deploy-blue-green.sh:

  1. Detect active slot & boot standby: Inspect /srv/reverse-proxy/conf.d/upstream.inc. If :3002 (nuxt-app-blue) is active, build and start nuxt-app-green on :3012 (and vice versa). Production traffic never pauses.
  2. 30-second healthcheck gate: Poll http://127.0.0.1:${STANDBY_PORT}/ every second for up to 30 seconds until HTTP 200 is returned. If the container fails to boot, abort immediately—the live slot stays untouched.
  3. Header self-test & SSR/SQLite warmup gate: Before routing a single live request to the standby container, verify both caching contracts directly against loopback and warm up V8 JIT + @nuxt/content SQLite caches across core routes (/, /blog, /en/blog, /about).
  4. Atomic cutover (mv -f + nginx -t && nginx -s reload): Write the new upstream file to upstream.inc.tmp, atomically replace upstream.inc via mv -f (same filesystem rename is atomic on POSIX), validate syntax with nginx -t, and reload Nginx workers gracefully so existing keepalive connections finish cleanly.
  5. 3-second graceful drain & retirement: Sleep 3 seconds to let any trailing in-flight requests on the old slot complete, then stop and remove the retired container.
bash
#!/usr/bin/env bash
set -euo pipefail

UPSTREAM_FILE="/srv/reverse-proxy/conf.d/upstream.inc"
INTERNAL_TEST_IP="203.0.113.10"

if grep -q "127.0.0.1:3002" "$UPSTREAM_FILE"; then
  OLD_SLOT="nuxt-app-blue"; OLD_PORT="3002"
  NEW_SLOT="nuxt-app-green"; NEW_PORT="3012"
else
  OLD_SLOT="nuxt-app-green"; OLD_PORT="3012"
  NEW_SLOT="nuxt-app-blue"; NEW_PORT="3002"
fi

# 1. Start standby container on NEW_PORT
docker compose -f /srv/apps/web/docker-compose.blue-green.yml up -d --force-recreate "$NEW_SLOT"

# 2. Pre-cutover 30s healthcheck gate
ready=0
for _ in $(seq 1 30); do
  if curl -fsS --max-time 2 "http://127.0.0.1:${NEW_PORT}/" > /dev/null; then
    ready=1
    break
  fi
  sleep 1
done
[ "$ready" -eq 1 ] || { echo "Standby healthcheck failed"; exit 1; }

# 3. SWR & /about internal-IP header self-test + SSR/SQLite warmup
curl -fsSI "http://127.0.0.1:${NEW_PORT}/" | grep -iq "s-maxage=300"
curl -fsSI -H "CF-Connecting-IP: ${INTERNAL_TEST_IP}" "http://127.0.0.1:${NEW_PORT}/about" \
  | grep -iq "CDN-Cache-Control: no-store"

for route in "/" "/about" "/blog" "/en/blog"; do
  curl -fsS --max-time 5 "http://127.0.0.1:${NEW_PORT}${route}" > /dev/null
done

# 4. Atomic upstream swap & graceful Nginx reload
cat > "${UPSTREAM_FILE}.tmp" <<EOF
server 127.0.0.1:${NEW_PORT} max_fails=2 fail_timeout=5s;
server 127.0.0.1:${OLD_PORT} backup;
EOF
mv -f "${UPSTREAM_FILE}.tmp" "$UPSTREAM_FILE"
nginx -t && nginx -s reload

# 5. 3-second graceful drain before retiring previous slot
sleep 3
docker stop "$OLD_SLOT" && docker rm "$OLD_SLOT"

4.2. Live Production Proof: 218 / 218 HTTP 200, 0 HTTP 502s

To prove zero downtime under real traffic rather than assuming nginx -s reload worked, we ran a continuous 1-second external HTTP probe hitting https://inmokang.com from start to finish of a full Blue-Green release—covering Docker image build, standby startup, SWR/internal header self-tests, SSR/SQLite warmup, atomic Nginx reload, and old-slot teardown.

Verification MetricIn-Place docker compose up -dAtomic Single-VPS Blue-Green Cutover
Total Continuous Probe Requests (1s interval)N/A (5–10s restart gap)218 requests
HTTP 200 OK ResponsesInterrupted during recreate218 / 218 (100.0%)
HTTP 502 / 503 / 504 ErrorsDeterministic during cold start0 errors
Broken Deploy Blast RadiusLive site goes down before rollback0% — aborted at pre-cutover gate
Cold-Start TTFB Spike on First UserFirst user pays V8 JIT + SQLite initAbsorbed by standby warmup gate

This is the exact same single-VPS zero-downtime deployment discipline we apply across our sibling production web platforms, including PhotoJob, where keeping single-node operational simplicity without sacrificing release reliability matters most.

4.3. Closing the Observability Loop: Eliminating 21.4% Clarity Dead Clicks with a Unified Article Lightbox

Because our 8-layer observability audit pulls Microsoft Clarity behavioral signals alongside Cloudflare and Nginx telemetry, one UX metric jumped off the page right next to our origin 502 count: 21.4% Dead Clicks and 3.6% Rage Clicks across technical deep-dive posts.

Replaying the Clarity heatmaps made the cause obvious within 30 seconds. Technical posts on inmokang.com rely heavily on dense architecture schematics, SVG comparison diagrams, and lighting layouts exported from our Photo Diagram tool. Readers on both mobile and desktop clicked directly on inline SVGs and diagram images expecting them to open full-screen—the same instant-zoom ergonomics we engineered earlier for hybrid photo archive search. When nothing happened, they clicked two or three times in frustration (triggering Clarity's Rage Click counter). Meanwhile, several non-interactive metadata callouts inherited ambiguous hover cursors that invited clicks into nowhere.

We shipped a clean two-part fix alongside the infrastructure hardening:

  • Unified Inline SVG + Image Lightbox (useArticleLightbox + ArticleLightboxModal): Automatically discovers article cover images, prose raster images, and inline <svg> diagrams (> 48px) while ignoring navigation icons and ad frames. Inline <svg> nodes are serialized once via XMLSerializer into a WeakMap-cached data:image/svg+xml URI, /_ipx/ image optimizer prefixes are unwrapped so gallery keys deduplicate cleanly, and the modal enforces full keyboard accessibility (Escape to close, ArrowLeft/ArrowRight gallery navigation, body scroll lock, focus trap, and focus restoration back to the triggering element).
  • Strict Visual Affordance Hygiene: Applied cursor: zoom-in exclusively to inspectable article diagrams and images, and locked non-interactive callouts, badges, and metadata rows to cursor: default so every visual cue promises only interactions that actually exist.

5. Frequently Asked Questions (FAQ)

Q1. Why does Node.js throw a V8 JavaScript heap out of memory error near 256 MB inside a 512 MB Docker container?

Node.js 20 inspects the container cgroup memory limit and applies V8's default 50% heuristic to size the Old Space heap. Inside a 512 MB Docker container, V8 caps Old Space near 256 MB even while the other half of container RAM sits unused. Under concurrent SSR bursts, garbage collection hits Mark-Compact thrashing near 258 MB and aborts with exit code 134. Raising mem_limit to 768m with memswap_limit: 1024m and setting NODE_OPTIONS=--max-old-space-size=512 doubles V8 headroom while preserving a 256 MB native RSS margin.

Q2. Why do Nuxt server/middleware handlers fail to run on prerendered routes like /about?

When a route is built with prerender: true in Nuxt, Nitro's serveStatic layer serves the pre-built HTML file directly from disk before standard server/middleware handlers execute. Any request-context flags normally populated by middleware—such as internal operator IP detection or analytics bypass flags—remain undefined when response-header plugins finalize Cache-Control headers. Extracting the logic into an idempotent utility called from Nitro's request lifecycle hook and as a fallback inside beforeResponse eliminates the blind spot.

Q3. How can you run zero-downtime Blue-Green deployments on a single VPS without Kubernetes?

Run two identical Docker container slots bound to distinct loopback ports (for example, nuxt-app-blue on 127.0.0.1:3002 and nuxt-app-green on 127.0.0.1:3012) behind a single host Nginx reverse proxy. Point Nginx to an isolated upstream include file (/srv/reverse-proxy/conf.d/upstream.inc), boot and warm up the standby slot, verify health and cache headers against the standby port, swap the include file atomically with mv -f, run nginx -t && nginx -s reload, and wait 3 seconds to drain in-flight requests before retiring the old container.

Q4. How do you separate true origin 502 errors from Cloudflare edge 5xx noise during post-incident forensics?

Query Cloudflare GraphQL analytics explicitly filtering on originResponseStatus >= 500 rather than relying solely on edgeResponseStatus, because edge-only timeouts or worker errors never touch your origin. Then align those exact UTC timestamps to the second against origin Nginx error logs (distinguishing 104: Connection reset by peer from 111: Connection refused) and container stdout/stderr restart logs. Three-layer timestamp correlation proves whether 502s came from deploys, upstream OOM crashes, or network drops.


Wrapping Up: A Production Reliability Checklist for Single-VPS Nuxt + Docker Stacks

Single-VPS architectures are fast, predictable, and cheap to operate—provided you close the subtle cracks between cgroups, framework lifecycles, and reverse-proxy cutovers. Before your next release, audit your stack against these five concrete checks:

  1. Correlate 502s across all three layers: Never assume HTTP 502s are deploy noise. Cross-check Cloudflare originResponseStatus >= 500, Nginx 104 vs. 111 socket codes, and container runtime logs to the exact second.
  2. Override V8's cgroup 50% default explicitly: Pair mem_limit: 768m, memswap_limit: 1024m, and NODE_OPTIONS=--max-old-space-size=512 so concurrent cacheStatus: bypass SSR traffic cannot starve V8 at 256 MB.
  3. Never trust server/middleware for prerender: true routes: Move request-classification and security/cache header guards into an idempotent utility executed inside Nitro's request hook (with response-finalization fallback) and mirror exclusions in Cloudflare Cache Rules.
  4. Replace in-place restarts with atomic Nginx Blue-Green: Run dual loopback slots (:3002 ↔ :3012), gate every swap behind a 30-second healthcheck + header self-test + SSR/SQLite warmup pass, swap upstream.inc atomically via mv -f, reload Nginx, and drain for 3 seconds.
  5. Pair backend telemetry with UX Dead Click audits: If readers are clicking dense technical SVGs expecting zoom, ship a keyboard-accessible inline SVG/image lightbox and reserve pointer cursors strictly for real interactive targets.