[{"data":1,"prerenderedAt":3496},["ShallowReactive",2],{"en-blog-detail-/en/blog/20261206-nuxt-docker-v8-oom-blue-green-zero-downtime-2026-12-06":3,"en-blog-linked-project-/en/blog/20261206-nuxt-docker-v8-oom-blue-green-zero-downtime-2026-12-06":3458,"en-blog-ko-counterpart-/en/blog/20261206-nuxt-docker-v8-oom-blue-green-zero-downtime-2026-12-06":3489,"en-blog-surround-/en/blog/20261206-nuxt-docker-v8-oom-blue-green-zero-downtime-2026-12-06":3490},{"id":4,"title":5,"adsEnabled":6,"author":7,"body":8,"buildLogLabel":3458,"category":3459,"coverImage":3460,"coverImageAlt":3461,"date":3462,"description":3463,"extension":3464,"faq":3465,"meta":3474,"navigation":6,"noindex":3475,"path":3476,"project":3458,"promo":3475,"seo":3477,"seoDescription":3463,"seoTitle":3478,"status":3479,"stem":3480,"tags":3481,"__hash__":3488},"enBlog/en/blog/20261206-Nuxt-Docker-V8-OOM-Blue-Green-Zero-Downtime.md","Fixing 16 Production 502s in Nuxt + Docker: V8 OOM, Nitro Prerender & Single-VPS Blue-Green",true,"KangSum",{"type":9,"value":10,"toc":3426},"minimark",[11,15,33,44,47,74,77,133,143,146,151,154,202,215,220,411,435,452,475,477,481,487,497,509,529,547,561,590,594,615,622,665,823,827,976,983,1000,1002,1011,1014,1032,1054,1057,1077,1110,1120,1123,1182,1203,1211,1214,1283,1841,1855,1979,1983,2118,2124,2126,2134,2149,2152,2156,2159,2185,2196,2218,2343,2349,2439,3069,3078,3089,3193,3201,3208,3223,3239,3242,3308,3310,3314,3318,3321,3325,3328,3332,3335,3339,3342,3344,3348,3351,3422],[12,13,5],"h1",{"id":14},"fixing-16-production-502s-in-nuxt-docker-v8-oom-nitro-prerender-single-vps-blue-green",[16,17,18,19,23,24,32],"p",{},"During a routine 8-layer production observability audit on ",[20,21,22],"code",{},"inmokang.com",", Cloudflare GraphQL telemetry surfaced ",[25,26,27,28,31],"strong",{},"16 true origin ",[20,29,30],{},"502 Bad Gateway"," errors"," on the apex domain. There had been no user complaints, no uptime pager alerts, and our synthetic checks were green.",[16,34,35,36],{},"My first instinct was the reflex almost every engineer reaches for on a single-VPS Docker stack: ",[37,38,39,40,43],"em",{},"\"We shipped four production releases over the past two days—those 16 errors are probably brief restart blips during ",[20,41,42],{},"docker compose up -d",".\"",[16,45,46],{},"That assumption was completely wrong.",[16,48,49,50,53,54,61,62,65,66,69,70,73],{},"Correlating Cloudflare GraphQL ",[20,51,52],{},"originResponseStatus"," events against Nginx proxy error logs and Docker container stdout to the exact second proved that ",[25,55,56,57,60],{},"all four production deploys produced ",[20,58,59],{},"0"," HTTP 502s",". Every single one of the 16 failures occurred inside a ",[25,63,64],{},"single 5-second runtime window"," caused by Node.js 20 hitting V8's default cgroup Old Space ceiling at ",[20,67,68],{},"258 MB"," inside a ",[20,71,72],{},"512 MB"," container.",[16,75,76],{},"Pulling on that thread exposed three compounding gaps—and a UX telemetry blind spot worth fixing in the same pass:",[78,79,80,99,117,123],"ol",{},[81,82,83,86,87,90,91,94,95,98],"li",{},[25,84,85],{},"V8 cgroup heap starvation:"," A ",[20,88,89],{},"mem_limit: 512m"," container silently capped V8 Old Space at ",[20,92,93],{},"~256 MB",", crashing under concurrent ",[20,96,97],{},"cacheStatus: bypass"," SSR bursts while half the container's RAM went unused.",[81,100,101,108,109,112,113,116],{},[25,102,103,104,107],{},"A Nitro ",[20,105,106],{},"serveStatic"," prerender blind spot:"," Prerendered static HTML routes like ",[20,110,111],{},"/about"," bypassed ",[20,114,115],{},"server/middleware",", causing internal operator requests to receive public edge-cache SWR headers.",[81,118,119,122],{},[25,120,121],{},"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.",[81,124,125,132],{},[25,126,127,128,131],{},"Clarity Dead Clicks (",[20,129,130],{},"21.4%","):"," Session telemetry from the same audit showed readers repeatedly clicking inline architecture SVGs expecting them to zoom.",[16,134,135,136,142],{},"This post walks through the exact 3-layer forensic trail, the production fixes for each layer, and the live ",[25,137,138,139,141],{},"218 / 218 HTTP 200 (",[20,140,59],{}," HTTP 502s)"," cutover verification on a single VPS.",[144,145],"hr",{},[147,148,150],"h2",{"id":149},"_1-three-layer-timestamp-forensics-why-all-16-origin-502s-had-nothing-to-do-with-deploys","1. Three-Layer Timestamp Forensics: Why All 16 Origin 502s Had Nothing to Do with Deploys",[16,152,153],{},"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:",[78,155,156,174,192],{},[81,157,158,161,162,165,166,169,170,173],{},[25,159,160],{},"Edge Layer (Cloudflare GraphQL):"," Filtered ",[20,163,164],{},"httpRequestsAdaptiveGroups"," strictly on ",[20,167,168],{},"originResponseStatus >= 500",", separating true origin failures from edge-only 5xx noise, while inspecting ",[20,171,172],{},"cacheStatus",", client IP, and requested path.",[81,175,176,179,180,183,184,187,188,191],{},[25,177,178],{},"Reverse-Proxy Layer (Nginx Error Logs):"," Inspected ",[20,181,182],{},"upstream"," socket error codes—specifically distinguishing ",[20,185,186],{},"104: Connection reset by peer"," (an active process dying mid-request) from ",[20,189,190],{},"111: Connection refused"," (the listening socket is down during container restart).",[81,193,194,197,198,201],{},[25,195,196],{},"Runtime Layer (Docker Container Logs):"," Checked ",[20,199,200],{},"docker logs --timestamps"," for Node.js V8 garbage-collection traces, exit codes, and Nitro startup timestamps.",[16,203,204,205,208,209,214],{},"Because we had previously configured strict ",[20,206,207],{},"CF-Connecting-IP"," real-IP restoration at Nginx—covered in our ",[210,211,213],"a",{"href":212},"/en/blog/20261119-cloudflare-cf-connecting-ip-multi-layer-botnet-defense","multi-layer botnet defense guide","—Nginx and Cloudflare logs lined up by client IP without being masked behind Cloudflare edge subnets.",[216,217,219],"h3",{"id":218},"_11-cross-layer-event-timeline-dec-35-utc","1.1. Cross-Layer Event Timeline (Dec 3–5, UTC)",[221,222,223,251],"table",{},[224,225,226],"thead",{},[227,228,229,234,242,245,248],"tr",{},[230,231,233],"th",{"align":232},"left","Event Window (UTC)",[230,235,237,238,241],{"align":236},"center","Layer 1: Cloudflare GraphQL (",[20,239,240],{},"originResponseStatus=502",")",[230,243,244],{"align":232},"Layer 2: Nginx Error Log Signal",[230,246,247],{"align":232},"Layer 3: Docker Container Runtime State",[230,249,250],{"align":232},"Root Cause Classification",[252,253,254,278,311,344,379],"tbody",{},[227,255,256,262,267,270,273],{},[257,258,259],"td",{"align":232},[25,260,261],{},"Dec 3–4 (4 Production Deploys)",[257,263,264],{"align":236},[25,265,266],{},"0 errors",[257,268,269],{"align":232},"No upstream errors recorded",[257,271,272],{"align":232},"Normal graceful stop and cold start during low-traffic windows",[257,274,275],{"align":232},[25,276,277],{},"Cleared — Not deploy-related",[227,279,280,288,297,303,306],{},[257,281,282],{"align":232},[25,283,284,285],{},"Dec 5 ",[20,286,287],{},"09:38:46Z–09:38:48Z",[257,289,290,291,293,294],{"align":236},"16+ concurrent requests with ",[20,292,97],{}," from ",[20,295,296],{},"198.51.100.42",[257,298,299,300],{"align":232},"Requests forwarded concurrently to upstream ",[20,301,302],{},":3002",[257,304,305],{"align":232},"V8 Old Space climbs rapidly under concurrent SSR + SQLite reads",[257,307,308],{"align":232},[25,309,310],{},"Traffic burst bypassing edge cache",[227,312,313,320,325,330,339],{},[257,314,315],{"align":232},[25,316,284,317],{},[20,318,319],{},"09:38:48Z",[257,321,322],{"align":236},[25,323,324],{},"5 × HTTP 502",[257,326,327],{"align":232},[20,328,329],{},"recv() failed (104: Connection reset by peer)",[257,331,332,335,336,241],{"align":232},[20,333,334],{},"FATAL ERROR: Reached heap limit"," → process aborts (",[20,337,338],{},"exit 134",[257,340,341],{"align":232},[25,342,343],{},"In-flight requests killed by V8 OOM",[227,345,346,353,358,363,374],{},[257,347,348],{"align":232},[25,349,284,350],{},[20,351,352],{},"09:38:49Z–09:38:53Z",[257,354,355],{"align":236},[25,356,357],{},"11 × HTTP 502",[257,359,360],{"align":232},[20,361,362],{},"connect() failed (111: Connection refused)",[257,364,365,366,369,370,373],{"align":232},"Docker ",[20,367,368],{},"restart: unless-stopped"," rebooting Nitro (",[20,371,372],{},"09:38:48Z → 09:38:55Z",", 7s downtime)",[257,375,376],{"align":232},[25,377,378],{},"Socket unavailable during 7s cold restart",[227,380,381,389,393,400,406],{},[257,382,383],{"align":232},[25,384,284,385,388],{},[20,386,387],{},"09:38:55Z"," onward",[257,390,391],{"align":236},[25,392,266],{},[257,394,395,396,399],{"align":232},"Clean ",[20,397,398],{},"200 OK"," responses restored",[257,401,402,403],{"align":232},"Fresh Nitro worker listening on ",[20,404,405],{},":3000",[257,407,408],{"align":232},[25,409,410],{},"Self-recovered after restart",[16,412,413,414,417,418,428,429,431,432,434],{},"The numbers locked together without a single stray error. Every single one of the ",[20,415,416],{},"16 / 16"," origin 502s fell inside a ",[25,419,420,421,424,425,241],{},"5-second burst (",[20,422,423],{},"2026-12-05T09:38:48Z"," through ",[20,426,427],{},"09:38:53Z"," triggered when a single client (",[20,430,296],{},") fired more than 16 concurrent ",[20,433,97],{}," SSR requests at once.",[16,436,437,438,441,442,445,446,451],{},"The split between ",[20,439,440],{},"5 × Connection reset by peer (104)"," and ",[20,443,444],{},"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 ",[25,447,448,449,241],{},"7-second window (",[20,450,372],{}," while Docker tore down the dead container and booted Nitro back up.",[453,454,455],"blockquote",{},[16,456,457,460,461,463,464,466,467,470,471,474],{},[25,458,459],{},"Key Takeaway:","\nNever blame unexplained ",[20,462,30],{}," errors on \"deploy blips\" by gut feel. Correlating Cloudflare ",[20,465,168],{},", Nginx ",[20,468,469],{},"104"," vs. ",[20,472,473],{},"111"," socket errors, and container timestamps to the second immediately separates release windows from runtime crashes.",[144,476],{},[147,478,480],{"id":479},"_2-why-nodejs-20-crashes-at-258-mb-inside-a-512-mb-docker-container","2. Why Node.js 20 Crashes at 258 MB Inside a 512 MB Docker Container",[16,482,483,484,486],{},"Opening the Docker logs right before ",[20,485,319],{}," revealed the smoking gun:",[488,489,495],"pre",{"className":490,"code":492,"language":493,"meta":494},[491],"language-text","\u003C--- Last few GCs --->\n[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\n[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\n\nFATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory\n","text","",[20,496,492],{"__ignoreMap":494},[16,498,499,500],{},"At first glance, that number looks broken: ",[25,501,502,503,505,506,508],{},"why did Node.js run out of memory at ",[20,504,68],{}," when Docker gave the container ",[20,507,89],{},"?",[16,510,511,512,515,516,518,519,522,523,528],{},"The answer lives in how Node.js 20 sizes the V8 heap inside Linux cgroups. When ",[20,513,514],{},"--max-old-space-size"," is omitted, Node.js reads the container's cgroup memory ceiling (",[20,517,72],{},") and applies a conservative ",[25,520,521],{},"~50% heuristic"," to cap V8's Old Space around ",[25,524,525],{},[20,526,527],{},"256 MB",". The runtime reserves the remaining half for native allocations, stack frames, and OS page cache.",[16,530,531,532,535,536,539,540,546],{},"In steady state, a Nuxt 4 + ",[20,533,534],{},"@nuxt/content"," v3 server serving cached routes idles comfortably around ",[20,537,538],{},"110–140 MB"," of V8 heap. Under a burst of ",[25,541,542,543,545],{},"16+ simultaneous ",[20,544,97],{}," SSR requests",", however, every concurrent request allocates:",[548,549,550,553,558],"ul",{},[81,551,552],{},"Vue SSR virtual DOM trees and payload serialization buffers,",[81,554,555,557],{},[20,556,534],{}," v3 SQLite query results and parsed MDC AST nodes,",[81,559,560],{},"Nitro response streams and head/SEO metadata objects.",[16,562,563,564,566,567,570,571,574,575,578,579,582,583,586,587],{},"Before V8's generational garbage collector can sweep short-lived objects from New Space, concurrent allocations promote into Old Space, slamming directly into the ",[20,565,93],{}," wall. ",[20,568,569],{},"Mark-Compact"," runs back-to-back cycles reclaiming barely ",[20,572,573],{},"1.2 MB"," (",[20,576,577],{},"251.2 -> 250.0 MB","), mutator utilization (",[20,580,581],{},"mu",") collapses to ",[20,584,585],{},"0.008",", and V8 aborts the process—",[25,588,589],{},"even though ~250 MB of the container's memory budget was never even touched.",[216,591,593],{"id":592},"_21-sizing-cgroup-memory-and-v8-old-space-intentionally","2.1. Sizing Cgroup Memory and V8 Old Space Intentionally",[16,595,596,597,599,600,603,604,607,608,574,611,614],{},"Blindly raising ",[20,598,514],{}," without raising the container's cgroup limit is dangerous: if V8 heap plus native RSS (",[20,601,602],{},"libuv",", OpenSSL buffers, V8 code space, SQLite page cache) exceeds ",[20,605,606],{},"mem_limit",", the Linux kernel OOM killer sends an immediate ",[20,609,610],{},"SIGKILL",[20,612,613],{},"exit 137",") with zero JavaScript stack trace.",[16,616,617,618,621],{},"Instead, we tuned all three memory boundaries together in ",[20,619,620],{},"docker-compose.yml",":",[548,623,624,632,643],{},[81,625,626,631],{},[25,627,628],{},[20,629,630],{},"mem_limit: 768m"," — raises the physical RAM ceiling by 50%.",[81,633,634,639,640,642],{},[25,635,636],{},[20,637,638],{},"memswap_limit: 1024m"," — provides a ",[20,641,527],{}," emergency swap cushion against transient native RSS spikes so the kernel never abruptly SIGKILLs the container.",[81,644,645,650,651,574,654,657,658,660,661,664],{},[25,646,647],{},[20,648,649],{},"NODE_OPTIONS=--max-old-space-size=512"," — explicitly ",[25,652,653],{},"doubles V8 Old Space headroom",[20,655,656],{},"~256 MB → 512 MB",") while preserving a deterministic ",[20,659,527],{}," physical RAM margin (",[20,662,663],{},"768 - 512 = 256 MB",") for non-V8 native memory.",[488,666,670],{"className":667,"code":668,"language":669,"meta":494,"style":494},"language-yaml shiki shiki-themes github-light github-dark","services:\n  nuxt-app-blue:\n    image: ${DOCKER_IMAGE:-web-app:latest}\n    container_name: nuxt-app-blue\n    restart: unless-stopped\n    mem_limit: 768m\n    memswap_limit: 1024m\n    ports:\n      - \"127.0.0.1:3002:3000\"\n    environment:\n      - NODE_ENV=production\n      - NODE_OPTIONS=--max-old-space-size=512\n      - NUXT_PUBLIC_SITE_URL=https://inmokang.com\n      - NUXT_SITE_URL=https://inmokang.com\n    networks:\n      - web-network\n","yaml",[20,671,672,685,693,706,717,728,739,750,758,767,775,783,791,799,807,815],{"__ignoreMap":494},[673,674,677,681],"span",{"class":675,"line":676},"line",1,[673,678,680],{"class":679},"s9eBZ","services",[673,682,684],{"class":683},"sVt8B",":\n",[673,686,688,691],{"class":675,"line":687},2,[673,689,690],{"class":679},"  nuxt-app-blue",[673,692,684],{"class":683},[673,694,696,699,702],{"class":675,"line":695},3,[673,697,698],{"class":679},"    image",[673,700,701],{"class":683},": ",[673,703,705],{"class":704},"sZZnC","${DOCKER_IMAGE:-web-app:latest}\n",[673,707,709,712,714],{"class":675,"line":708},4,[673,710,711],{"class":679},"    container_name",[673,713,701],{"class":683},[673,715,716],{"class":704},"nuxt-app-blue\n",[673,718,720,723,725],{"class":675,"line":719},5,[673,721,722],{"class":679},"    restart",[673,724,701],{"class":683},[673,726,727],{"class":704},"unless-stopped\n",[673,729,731,734,736],{"class":675,"line":730},6,[673,732,733],{"class":679},"    mem_limit",[673,735,701],{"class":683},[673,737,738],{"class":704},"768m\n",[673,740,742,745,747],{"class":675,"line":741},7,[673,743,744],{"class":679},"    memswap_limit",[673,746,701],{"class":683},[673,748,749],{"class":704},"1024m\n",[673,751,753,756],{"class":675,"line":752},8,[673,754,755],{"class":679},"    ports",[673,757,684],{"class":683},[673,759,761,764],{"class":675,"line":760},9,[673,762,763],{"class":683},"      - ",[673,765,766],{"class":704},"\"127.0.0.1:3002:3000\"\n",[673,768,770,773],{"class":675,"line":769},10,[673,771,772],{"class":679},"    environment",[673,774,684],{"class":683},[673,776,778,780],{"class":675,"line":777},11,[673,779,763],{"class":683},[673,781,782],{"class":704},"NODE_ENV=production\n",[673,784,786,788],{"class":675,"line":785},12,[673,787,763],{"class":683},[673,789,790],{"class":704},"NODE_OPTIONS=--max-old-space-size=512\n",[673,792,794,796],{"class":675,"line":793},13,[673,795,763],{"class":683},[673,797,798],{"class":704},"NUXT_PUBLIC_SITE_URL=https://inmokang.com\n",[673,800,802,804],{"class":675,"line":801},14,[673,803,763],{"class":683},[673,805,806],{"class":704},"NUXT_SITE_URL=https://inmokang.com\n",[673,808,810,813],{"class":675,"line":809},15,[673,811,812],{"class":679},"    networks",[673,814,684],{"class":683},[673,816,818,820],{"class":675,"line":817},16,[673,819,763],{"class":683},[673,821,822],{"class":704},"web-network\n",[216,824,826],{"id":825},"_22-before-vs-after-memory-budget-comparison","2.2. Before vs. After Memory Budget Comparison",[221,828,829,845],{},[224,830,831],{},[227,832,833,836,839,842],{},[230,834,835],{"align":232},"Parameter",[230,837,838],{"align":232},"Before (Incident Baseline)",[230,840,841],{"align":232},"After (Hardened Production)",[230,843,844],{"align":232},"Operational Impact",[252,846,847,870,898,926,951],{},[227,848,849,855,860,867],{},[257,850,851],{"align":232},[25,852,365,853],{},[20,854,606],{},[257,856,857],{"align":232},[20,858,859],{},"512m",[257,861,862],{"align":232},[25,863,864],{},[20,865,866],{},"768m",[257,868,869],{"align":232},"+256 MB physical RAM ceiling",[227,871,872,879,882,893],{},[257,873,874],{"align":232},[25,875,365,876],{},[20,877,878],{},"memswap_limit",[257,880,881],{"align":232},"Default (uncontrolled / equal)",[257,883,884,574,889,892],{"align":232},[25,885,886],{},[20,887,888],{},"1024m",[20,890,891],{},"+256m"," swap cushion)",[257,894,895,896],{"align":232},"Absorbs brief native RSS bursts without ",[20,897,610],{},[227,899,900,905,910,920],{},[257,901,902],{"align":232},[25,903,904],{},"V8 Old Space Ceiling",[257,906,907,908,241],{"align":232},"Implicit cgroup 50% (",[20,909,93],{},[257,911,912,574,917,241],{"align":232},[25,913,914,915],{},"Explicit ",[20,916,72],{},[20,918,919],{},"--max-old-space-size=512",[257,921,922,925],{"align":232},[25,923,924],{},"2.0× JavaScript heap headroom"," under SSR spikes",[227,927,928,933,938,948],{},[257,929,930],{"align":232},[25,931,932],{},"Non-V8 Native RSS Margin",[257,934,935,937],{"align":232},[20,936,93],{}," (unused while V8 crashed)",[257,939,940],{"align":232},[25,941,942,944,945,947],{},[20,943,527],{}," RAM + ",[20,946,527],{}," swap",[257,949,950],{"align":232},"Balanced budget for SQLite, libuv, and TLS buffers",[227,952,953,958,967,973],{},[257,954,955],{"align":232},[25,956,957],{},"Observed Failure Mode",[257,959,960,963,964,966],{"align":232},[20,961,962],{},"Mark-Compact 251.2 (258.0) MB"," → OOM ",[20,965,338],{}," + 7s outage",[257,968,969,972],{"align":232},[25,970,971],{},"0 OOM restarts"," under concurrent SSR stress",[257,974,975],{"align":232},"Eliminates single-client bypass crash vector",[16,977,978],{},[979,980],"img",{"alt":981,"src":982},"Before and after architecture comparison: 512 MB cgroup V8 256 MB OOM crash causing 16 HTTP 502 errors during a 7-second restart versus 768 MB cgroup with 512 MB V8 Old Space, standby warmup gate, and atomic Nginx Blue-Green cutover achieving 218/218 HTTP 200","/images/content-images/blog/20261206-Nuxt-Docker-V8-OOM-Blue-Green-Zero-Downtime/20261206-Nuxt-Docker-V8-OOM-Blue-Green-Zero-Downtime002-en.png",[453,984,985],{},[16,986,987,989,990,992,993,995,996,999],{},[25,988,459],{},"\nNever rely on Node.js's implicit cgroup memory heuristic inside small Docker containers. Always pair ",[20,991,606],{},", ",[20,994,878],{},", and an explicit ",[20,997,998],{},"NODE_OPTIONS=--max-old-space-size"," so V8 Old Space gets ~65% of container RAM and native RSS keeps a hard 256 MB buffer.",[144,1001],{},[147,1003,1005,1006,1008,1009,241],{"id":1004},"_3-closing-the-nitro-servestatic-blind-spot-on-prerendered-routes-about","3. Closing the Nitro ",[20,1007,106],{}," Blind Spot on Prerendered Routes (",[20,1010,111],{},[16,1012,1013],{},"Fixing the V8 crash explained the 16 origin 502s, but our 8-layer header audit flagged a second anomaly right beside it.",[16,1015,1016,1017,1020,1021,1024,1025,992,1028,1031],{},"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 (",[20,1018,1019],{},"203.0.113.10","), an explicit query parameter (",[20,1022,1023],{},"?internal_bypass=1","), and internal bypass cookies (",[20,1026,1027],{},"_ignore_analytics=1",[20,1029,1030],{},"internal_ip_flag=1","). When internal traffic is detected, Nitro stamps:",[488,1033,1037],{"className":1034,"code":1035,"language":1036,"meta":494,"style":494},"language-http shiki shiki-themes github-light github-dark","Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate\nCDN-Cache-Control: no-store\nCloudflare-CDN-Cache-Control: no-store\n","http",[20,1038,1039,1044,1049],{"__ignoreMap":494},[673,1040,1041],{"class":675,"line":676},[673,1042,1043],{},"Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate\n",[673,1045,1046],{"class":675,"line":687},[673,1047,1048],{},"CDN-Cache-Control: no-store\n",[673,1050,1051],{"class":675,"line":695},[673,1052,1053],{},"Cloudflare-CDN-Cache-Control: no-store\n",[16,1055,1056],{},"Meanwhile, public visitors receive edge-friendly Stale-While-Revalidate (SWR) caching:",[488,1058,1060],{"className":1034,"code":1059,"language":1036,"meta":494,"style":494},"Cache-Control: public, max-age=0, must-revalidate\nCDN-Cache-Control: public, s-maxage=300, stale-while-revalidate=3600\nCloudflare-CDN-Cache-Control: public, s-maxage=300, stale-while-revalidate=3600\n",[20,1061,1062,1067,1072],{"__ignoreMap":494},[673,1063,1064],{"class":675,"line":676},[673,1065,1066],{},"Cache-Control: public, max-age=0, must-revalidate\n",[673,1068,1069],{"class":675,"line":687},[673,1070,1071],{},"CDN-Cache-Control: public, s-maxage=300, stale-while-revalidate=3600\n",[673,1073,1074],{"class":675,"line":695},[673,1075,1076],{},"Cloudflare-CDN-Cache-Control: public, s-maxage=300, stale-while-revalidate=3600\n",[16,1078,1079,1080,992,1083,992,1086,1089,1090,1092,1093,1096,1097,1099,1100,1105,1106,1109],{},"On every dynamic SSR route (",[20,1081,1082],{},"/",[20,1084,1085],{},"/blog/...",[20,1087,1088],{},"/en/blog/...","), this worked exactly as designed. Yet when we probed ",[20,1091,111],{},"—which is configured with ",[20,1094,1095],{},"routeRules: { '/about': { prerender: true } }","—from our internal operator IP (",[20,1098,1019],{},"), Nitro returned ",[25,1101,1102],{},[20,1103,1104],{},"CDN-Cache-Control: public, s-maxage=300, stale-while-revalidate=3600"," instead of ",[20,1107,1108],{},"no-store",".",[216,1111,1113,1114,1117,1118],{"id":1112},"_31-why-prerender-true-bypasses-servermiddleware","3.1. Why ",[20,1115,1116],{},"prerender: true"," Bypasses ",[20,1119,115],{},[16,1121,1122],{},"The bug came down to Nitro's request pipeline execution order:",[78,1124,1125,1143,1167],{},[81,1126,1127,1128,1131,1132,1135,1136,574,1139,1142],{},"For standard SSR routes, requests enter Nitro → run ",[20,1129,1130],{},"server/middleware/*"," (which previously set ",[20,1133,1134],{},"event.context.isInternalTraffic = true",") → execute the Nuxt renderer → run ",[20,1137,1138],{},"server/plugins/seo-headers.ts",[20,1140,1141],{},"beforeResponse",").",[81,1144,1145,1146,1151,1152,1155,1156,1161,1162,1109],{},"For ",[25,1147,1148,1150],{},[20,1149,1116],{}," routes",", Nitro compiles ",[20,1153,1154],{},"/about/index.html"," into the static asset bundle at build time. At runtime, Nitro's internal ",[25,1157,1158,1160],{},[20,1159,106],{}," handler intercepts the request early"," and streams the pre-built HTML file directly from disk—",[25,1163,1164,1165],{},"completely bypassing ",[20,1166,1130],{},[81,1168,1169,1170,1173,1174,1177,1178,1181],{},"When ",[20,1171,1172],{},"seo-headers.ts"," ran at header finalization, ",[20,1175,1176],{},"event.context.isInternalTraffic"," was still ",[20,1179,1180],{},"undefined",". The plugin treated the internal request as an external public visitor and stamped public SWR cache headers onto the response.",[16,1183,1184,1185,1188,1189,1192,1193,1196,1197,1199,1200,1202],{},"Worse still, Nitro's static/SWR response path can flush ",[20,1186,1187],{},"304 Not Modified"," or call ",[20,1190,1191],{},"res.writeHead()"," / ",[20,1194,1195],{},"res.end()"," before H3's ",[20,1198,1141],{}," hook executes, meaning a single ",[20,1201,1141],{}," hook alone is not airtight.",[216,1204,1206,1207,1210],{"id":1205},"_32-unifying-internal-traffic-detection-via-idempotent-utility-nitro-request-hook","3.2. Unifying Internal Traffic Detection via Idempotent Utility + Nitro ",[20,1208,1209],{},"request"," Hook",[16,1212,1213],{},"We fixed the blind spot permanently in three steps:",[78,1215,1216,1229,1267],{},[81,1217,1218,1224,1225,1228],{},[25,1219,1220,1221,131],{},"Extract an idempotent evaluator (",[20,1222,1223],{},"server/utils/internalTraffic.ts"," Guard execution with ",[20,1226,1227],{},"event.context._internalTrafficEvaluated"," so calling it from multiple lifecycle stages never duplicates cookie mutations or header work.",[81,1230,1231,1240,1241,1244,1245,1248,1249,1251,1252,441,1255,1258,1259,1262,1263,1266],{},[25,1232,1233,1234,1236,1237,621],{},"Hook the earliest Nitro lifecycle entry (",[20,1235,1209],{},") plus fallback in ",[20,1238,1239],{},"applyResponseCacheHeaders"," Running ",[20,1242,1243],{},"evaluateInternalTraffic(event)"," inside ",[20,1246,1247],{},"nitroApp.hooks.hook('request', ...)"," guarantees every request—SSR, prerendered ",[20,1250,106],{},", or feed route—is classified before static file serving begins. Wrapping ",[20,1253,1254],{},"res.writeHead",[20,1256,1257],{},"res.end"," in ",[20,1260,1261],{},"guardResponseLifecycle(event)"," guarantees ",[20,1264,1265],{},"applyResponseCacheHeaders(event)"," executes before headers hit the wire.",[81,1268,1269,1272,1273,992,1276,992,1278,1280,1281,1109],{},[25,1270,1271],{},"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 ",[20,1274,1275],{},"internal_bypass=1",[20,1277,1027],{},[20,1279,1030],{},", and internal operator IP ",[20,1282,1019],{},[488,1284,1288],{"className":1285,"code":1286,"language":1287,"meta":494,"style":494},"language-ts shiki shiki-themes github-light github-dark","// server/utils/internalTraffic.ts (sanitized)\nimport { type H3Event, getCookie, getRequestHeader, getRequestURL, setCookie, setResponseHeader } from 'h3'\n\nconst INTERNAL_EXCLUDED_IPS = new Set\u003Cstring>(['203.0.113.10'])\nconst IGNORE_COOKIE = '_ignore_analytics'\nconst INTERNAL_IP_COOKIE = 'internal_ip_flag'\n\nexport function evaluateInternalTraffic(event: H3Event): void {\n  if (event.context._internalTrafficEvaluated) return\n  event.context._internalTrafficEvaluated = true\n\n  const clientIp = (\n    getRequestHeader(event, 'cf-connecting-ip')\n    || getRequestHeader(event, 'x-real-ip')\n    || getRequestHeader(event, 'x-forwarded-for')\n    || ''\n  ).split(',')[0]?.trim() || ''\n\n  const url = getRequestURL(event)\n  const isExcludedIp = Boolean(clientIp && INTERNAL_EXCLUDED_IPS.has(clientIp))\n  const hasIgnoreCookie = getCookie(event, IGNORE_COOKIE) === '1'\n  const hasBypassQuery = url.searchParams.get('internal_bypass') === '1'\n\n  event.context.isInternalTraffic = Boolean(\n    import.meta.dev || isExcludedIp || hasIgnoreCookie || hasBypassQuery,\n  )\n\n  if (isExcludedIp) {\n    setCookie(event, INTERNAL_IP_COOKIE, '1', { path: '/', sameSite: 'lax', httpOnly: false })\n    event.context.internalIpCookieMutated = true\n  }\n\n  if (event.context.isInternalTraffic || event.context.internalIpCookieMutated) {\n    setResponseHeader(event, 'Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate')\n    setResponseHeader(event, 'CDN-Cache-Control', 'no-store')\n    setResponseHeader(event, 'Cloudflare-CDN-Cache-Control', 'no-store')\n  }\n}\n","ts",[20,1289,1290,1296,1317,1322,1356,1368,1380,1384,1417,1428,1439,1443,1456,1470,1485,1498,1505,1538,1543,1559,1588,1615,1642,1647,1660,1689,1695,1700,1708,1745,1755,1761,1766,1779,1797,1814,1830,1835],{"__ignoreMap":494},[673,1291,1292],{"class":675,"line":676},[673,1293,1295],{"class":1294},"sJ8bj","// server/utils/internalTraffic.ts (sanitized)\n",[673,1297,1298,1302,1305,1308,1311,1314],{"class":675,"line":687},[673,1299,1301],{"class":1300},"szBVR","import",[673,1303,1304],{"class":683}," { ",[673,1306,1307],{"class":1300},"type",[673,1309,1310],{"class":683}," H3Event, getCookie, getRequestHeader, getRequestURL, setCookie, setResponseHeader } ",[673,1312,1313],{"class":1300},"from",[673,1315,1316],{"class":704}," 'h3'\n",[673,1318,1319],{"class":675,"line":695},[673,1320,1321],{"emptyLinePlaceholder":6},"\n",[673,1323,1324,1327,1331,1334,1337,1341,1344,1347,1350,1353],{"class":675,"line":708},[673,1325,1326],{"class":1300},"const",[673,1328,1330],{"class":1329},"sj4cs"," INTERNAL_EXCLUDED_IPS",[673,1332,1333],{"class":1300}," =",[673,1335,1336],{"class":1300}," new",[673,1338,1340],{"class":1339},"sScJk"," Set",[673,1342,1343],{"class":683},"\u003C",[673,1345,1346],{"class":1329},"string",[673,1348,1349],{"class":683},">([",[673,1351,1352],{"class":704},"'203.0.113.10'",[673,1354,1355],{"class":683},"])\n",[673,1357,1358,1360,1363,1365],{"class":675,"line":719},[673,1359,1326],{"class":1300},[673,1361,1362],{"class":1329}," IGNORE_COOKIE",[673,1364,1333],{"class":1300},[673,1366,1367],{"class":704}," '_ignore_analytics'\n",[673,1369,1370,1372,1375,1377],{"class":675,"line":730},[673,1371,1326],{"class":1300},[673,1373,1374],{"class":1329}," INTERNAL_IP_COOKIE",[673,1376,1333],{"class":1300},[673,1378,1379],{"class":704}," 'internal_ip_flag'\n",[673,1381,1382],{"class":675,"line":741},[673,1383,1321],{"emptyLinePlaceholder":6},[673,1385,1386,1389,1392,1395,1398,1402,1404,1407,1409,1411,1414],{"class":675,"line":752},[673,1387,1388],{"class":1300},"export",[673,1390,1391],{"class":1300}," function",[673,1393,1394],{"class":1339}," evaluateInternalTraffic",[673,1396,1397],{"class":683},"(",[673,1399,1401],{"class":1400},"s4XuR","event",[673,1403,621],{"class":1300},[673,1405,1406],{"class":1339}," H3Event",[673,1408,241],{"class":683},[673,1410,621],{"class":1300},[673,1412,1413],{"class":1329}," void",[673,1415,1416],{"class":683}," {\n",[673,1418,1419,1422,1425],{"class":675,"line":760},[673,1420,1421],{"class":1300},"  if",[673,1423,1424],{"class":683}," (event.context._internalTrafficEvaluated) ",[673,1426,1427],{"class":1300},"return\n",[673,1429,1430,1433,1436],{"class":675,"line":769},[673,1431,1432],{"class":683},"  event.context._internalTrafficEvaluated ",[673,1434,1435],{"class":1300},"=",[673,1437,1438],{"class":1329}," true\n",[673,1440,1441],{"class":675,"line":777},[673,1442,1321],{"emptyLinePlaceholder":6},[673,1444,1445,1448,1451,1453],{"class":675,"line":785},[673,1446,1447],{"class":1300},"  const",[673,1449,1450],{"class":1339}," clientIp",[673,1452,1333],{"class":1300},[673,1454,1455],{"class":683}," (\n",[673,1457,1458,1461,1464,1467],{"class":675,"line":793},[673,1459,1460],{"class":1339},"    getRequestHeader",[673,1462,1463],{"class":683},"(event, ",[673,1465,1466],{"class":704},"'cf-connecting-ip'",[673,1468,1469],{"class":683},")\n",[673,1471,1472,1475,1478,1480,1483],{"class":675,"line":801},[673,1473,1474],{"class":1300},"    ||",[673,1476,1477],{"class":1339}," getRequestHeader",[673,1479,1463],{"class":683},[673,1481,1482],{"class":704},"'x-real-ip'",[673,1484,1469],{"class":683},[673,1486,1487,1489,1491,1493,1496],{"class":675,"line":809},[673,1488,1474],{"class":1300},[673,1490,1477],{"class":1339},[673,1492,1463],{"class":683},[673,1494,1495],{"class":704},"'x-forwarded-for'",[673,1497,1469],{"class":683},[673,1499,1500,1502],{"class":675,"line":817},[673,1501,1474],{"class":1300},[673,1503,1504],{"class":704}," ''\n",[673,1506,1508,1511,1514,1516,1519,1522,1524,1527,1530,1533,1536],{"class":675,"line":1507},17,[673,1509,1510],{"class":683},"  ).",[673,1512,1513],{"class":1339},"split",[673,1515,1397],{"class":683},[673,1517,1518],{"class":704},"','",[673,1520,1521],{"class":683},")[",[673,1523,59],{"class":1329},[673,1525,1526],{"class":683},"]?.",[673,1528,1529],{"class":1339},"trim",[673,1531,1532],{"class":683},"() ",[673,1534,1535],{"class":1300},"||",[673,1537,1504],{"class":704},[673,1539,1541],{"class":675,"line":1540},18,[673,1542,1321],{"emptyLinePlaceholder":6},[673,1544,1546,1548,1551,1553,1556],{"class":675,"line":1545},19,[673,1547,1447],{"class":1300},[673,1549,1550],{"class":1329}," url",[673,1552,1333],{"class":1300},[673,1554,1555],{"class":1339}," getRequestURL",[673,1557,1558],{"class":683},"(event)\n",[673,1560,1562,1564,1567,1569,1572,1575,1578,1580,1582,1585],{"class":675,"line":1561},20,[673,1563,1447],{"class":1300},[673,1565,1566],{"class":1329}," isExcludedIp",[673,1568,1333],{"class":1300},[673,1570,1571],{"class":1339}," Boolean",[673,1573,1574],{"class":683},"(clientIp ",[673,1576,1577],{"class":1300},"&&",[673,1579,1330],{"class":1329},[673,1581,1109],{"class":683},[673,1583,1584],{"class":1339},"has",[673,1586,1587],{"class":683},"(clientIp))\n",[673,1589,1591,1593,1596,1598,1601,1603,1606,1609,1612],{"class":675,"line":1590},21,[673,1592,1447],{"class":1300},[673,1594,1595],{"class":1329}," hasIgnoreCookie",[673,1597,1333],{"class":1300},[673,1599,1600],{"class":1339}," getCookie",[673,1602,1463],{"class":683},[673,1604,1605],{"class":1329},"IGNORE_COOKIE",[673,1607,1608],{"class":683},") ",[673,1610,1611],{"class":1300},"===",[673,1613,1614],{"class":704}," '1'\n",[673,1616,1618,1620,1623,1625,1628,1631,1633,1636,1638,1640],{"class":675,"line":1617},22,[673,1619,1447],{"class":1300},[673,1621,1622],{"class":1329}," hasBypassQuery",[673,1624,1333],{"class":1300},[673,1626,1627],{"class":683}," url.searchParams.",[673,1629,1630],{"class":1339},"get",[673,1632,1397],{"class":683},[673,1634,1635],{"class":704},"'internal_bypass'",[673,1637,1608],{"class":683},[673,1639,1611],{"class":1300},[673,1641,1614],{"class":704},[673,1643,1645],{"class":675,"line":1644},23,[673,1646,1321],{"emptyLinePlaceholder":6},[673,1648,1650,1653,1655,1657],{"class":675,"line":1649},24,[673,1651,1652],{"class":683},"  event.context.isInternalTraffic ",[673,1654,1435],{"class":1300},[673,1656,1571],{"class":1339},[673,1658,1659],{"class":683},"(\n",[673,1661,1663,1666,1668,1671,1674,1676,1679,1681,1684,1686],{"class":675,"line":1662},25,[673,1664,1665],{"class":1300},"    import",[673,1667,1109],{"class":683},[673,1669,1670],{"class":1329},"meta",[673,1672,1673],{"class":683},".dev ",[673,1675,1535],{"class":1300},[673,1677,1678],{"class":683}," isExcludedIp ",[673,1680,1535],{"class":1300},[673,1682,1683],{"class":683}," hasIgnoreCookie ",[673,1685,1535],{"class":1300},[673,1687,1688],{"class":683}," hasBypassQuery,\n",[673,1690,1692],{"class":675,"line":1691},26,[673,1693,1694],{"class":683},"  )\n",[673,1696,1698],{"class":675,"line":1697},27,[673,1699,1321],{"emptyLinePlaceholder":6},[673,1701,1703,1705],{"class":675,"line":1702},28,[673,1704,1421],{"class":1300},[673,1706,1707],{"class":683}," (isExcludedIp) {\n",[673,1709,1711,1714,1716,1719,1721,1724,1727,1730,1733,1736,1739,1742],{"class":675,"line":1710},29,[673,1712,1713],{"class":1339},"    setCookie",[673,1715,1463],{"class":683},[673,1717,1718],{"class":1329},"INTERNAL_IP_COOKIE",[673,1720,992],{"class":683},[673,1722,1723],{"class":704},"'1'",[673,1725,1726],{"class":683},", { path: ",[673,1728,1729],{"class":704},"'/'",[673,1731,1732],{"class":683},", sameSite: ",[673,1734,1735],{"class":704},"'lax'",[673,1737,1738],{"class":683},", httpOnly: ",[673,1740,1741],{"class":1329},"false",[673,1743,1744],{"class":683}," })\n",[673,1746,1748,1751,1753],{"class":675,"line":1747},30,[673,1749,1750],{"class":683},"    event.context.internalIpCookieMutated ",[673,1752,1435],{"class":1300},[673,1754,1438],{"class":1329},[673,1756,1758],{"class":675,"line":1757},31,[673,1759,1760],{"class":683},"  }\n",[673,1762,1764],{"class":675,"line":1763},32,[673,1765,1321],{"emptyLinePlaceholder":6},[673,1767,1769,1771,1774,1776],{"class":675,"line":1768},33,[673,1770,1421],{"class":1300},[673,1772,1773],{"class":683}," (event.context.isInternalTraffic ",[673,1775,1535],{"class":1300},[673,1777,1778],{"class":683}," event.context.internalIpCookieMutated) {\n",[673,1780,1782,1785,1787,1790,1792,1795],{"class":675,"line":1781},34,[673,1783,1784],{"class":1339},"    setResponseHeader",[673,1786,1463],{"class":683},[673,1788,1789],{"class":704},"'Cache-Control'",[673,1791,992],{"class":683},[673,1793,1794],{"class":704},"'private, no-cache, no-store, max-age=0, must-revalidate'",[673,1796,1469],{"class":683},[673,1798,1800,1802,1804,1807,1809,1812],{"class":675,"line":1799},35,[673,1801,1784],{"class":1339},[673,1803,1463],{"class":683},[673,1805,1806],{"class":704},"'CDN-Cache-Control'",[673,1808,992],{"class":683},[673,1810,1811],{"class":704},"'no-store'",[673,1813,1469],{"class":683},[673,1815,1817,1819,1821,1824,1826,1828],{"class":675,"line":1816},36,[673,1818,1784],{"class":1339},[673,1820,1463],{"class":683},[673,1822,1823],{"class":704},"'Cloudflare-CDN-Cache-Control'",[673,1825,992],{"class":683},[673,1827,1811],{"class":704},[673,1829,1469],{"class":683},[673,1831,1833],{"class":675,"line":1832},37,[673,1834,1760],{"class":683},[673,1836,1838],{"class":675,"line":1837},38,[673,1839,1840],{"class":683},"}\n",[16,1842,1843,1844,1846,1847,1849,1850,1852,1853,621],{},"And inside ",[20,1845,1138],{},", both the Nitro ",[20,1848,1209],{}," hook and ",[20,1851,1239],{}," call ",[20,1854,1243],{},[488,1856,1858],{"className":1285,"code":1857,"language":1287,"meta":494,"style":494},"// server/plugins/seo-headers.ts (excerpt)\nexport default defineNitroPlugin((nitroApp) => {\n  nitroApp.hooks.hook('request', (event) => {\n    evaluateInternalTraffic(event)\n    guardResponseLifecycle(event) // intercepts writeHead/end before flush\n  })\n\n  nitroApp.hooks.hook('beforeResponse', (event) => {\n    applyResponseCacheHeaders(event) // idempotent fallback\n  })\n})\n",[20,1859,1860,1865,1888,1912,1919,1930,1935,1939,1960,1970,1974],{"__ignoreMap":494},[673,1861,1862],{"class":675,"line":676},[673,1863,1864],{"class":1294},"// server/plugins/seo-headers.ts (excerpt)\n",[673,1866,1867,1869,1872,1875,1878,1881,1883,1886],{"class":675,"line":687},[673,1868,1388],{"class":1300},[673,1870,1871],{"class":1300}," default",[673,1873,1874],{"class":1339}," defineNitroPlugin",[673,1876,1877],{"class":683},"((",[673,1879,1880],{"class":1400},"nitroApp",[673,1882,1608],{"class":683},[673,1884,1885],{"class":1300},"=>",[673,1887,1416],{"class":683},[673,1889,1890,1893,1896,1898,1901,1904,1906,1908,1910],{"class":675,"line":695},[673,1891,1892],{"class":683},"  nitroApp.hooks.",[673,1894,1895],{"class":1339},"hook",[673,1897,1397],{"class":683},[673,1899,1900],{"class":704},"'request'",[673,1902,1903],{"class":683},", (",[673,1905,1401],{"class":1400},[673,1907,1608],{"class":683},[673,1909,1885],{"class":1300},[673,1911,1416],{"class":683},[673,1913,1914,1917],{"class":675,"line":708},[673,1915,1916],{"class":1339},"    evaluateInternalTraffic",[673,1918,1558],{"class":683},[673,1920,1921,1924,1927],{"class":675,"line":719},[673,1922,1923],{"class":1339},"    guardResponseLifecycle",[673,1925,1926],{"class":683},"(event) ",[673,1928,1929],{"class":1294},"// intercepts writeHead/end before flush\n",[673,1931,1932],{"class":675,"line":730},[673,1933,1934],{"class":683},"  })\n",[673,1936,1937],{"class":675,"line":741},[673,1938,1321],{"emptyLinePlaceholder":6},[673,1940,1941,1943,1945,1947,1950,1952,1954,1956,1958],{"class":675,"line":752},[673,1942,1892],{"class":683},[673,1944,1895],{"class":1339},[673,1946,1397],{"class":683},[673,1948,1949],{"class":704},"'beforeResponse'",[673,1951,1903],{"class":683},[673,1953,1401],{"class":1400},[673,1955,1608],{"class":683},[673,1957,1885],{"class":1300},[673,1959,1416],{"class":683},[673,1961,1962,1965,1967],{"class":675,"line":760},[673,1963,1964],{"class":1339},"    applyResponseCacheHeaders",[673,1966,1926],{"class":683},[673,1968,1969],{"class":1294},"// idempotent fallback\n",[673,1971,1972],{"class":675,"line":769},[673,1973,1934],{"class":683},[673,1975,1976],{"class":675,"line":777},[673,1977,1978],{"class":683},"})\n",[216,1980,1982],{"id":1981},"_33-verified-header-behavior-matrix-after-refactor","3.3. Verified Header Behavior Matrix After Refactor",[221,1984,1985,2009],{},[224,1986,1987],{},[227,1988,1989,1992,1995,1998,2004],{},[230,1990,1991],{"align":232},"Route Type",[230,1993,1994],{"align":232},"Visitor Class",[230,1996,1997],{"align":232},"Cloudflare Edge Cache Rule",[230,1999,2000,2001],{"align":232},"Origin ",[20,2002,2003],{},"Cache-Control",[230,2005,2000,2006],{"align":232},[20,2007,2008],{},"CDN-Cache-Control",[252,2010,2011,2042,2069,2094],{},[227,2012,2013,2020,2023,2032,2037],{},[257,2014,2015],{"align":232},[25,2016,2017,2018,241],{},"Dynamic SSR (",[20,2019,1085],{},[257,2021,2022],{"align":232},"External Public",[257,2024,2025,2026,1192,2029,241],{"align":232},"Eligible for SWR (",[20,2027,2028],{},"HIT",[20,2030,2031],{},"STALE",[257,2033,2034],{"align":232},[20,2035,2036],{},"public, max-age=0, must-revalidate",[257,2038,2039],{"align":232},[20,2040,2041],{},"public, s-maxage=300, stale-while-revalidate=3600",[227,2043,2044,2050,2057,2060,2065],{},[257,2045,2046],{"align":232},[25,2047,2017,2048,241],{},[20,2049,1085],{},[257,2051,2052,2053,1192,2055,241],{"align":232},"Internal (",[20,2054,1019],{},[20,2056,1275],{},[257,2058,2059],{"align":232},"Bypassed at Edge",[257,2061,2062],{"align":232},[20,2063,2064],{},"private, no-cache, no-store, max-age=0, must-revalidate",[257,2066,2067],{"align":232},[20,2068,1108],{},[227,2070,2071,2078,2080,2086,2090],{},[257,2072,2073],{"align":232},[25,2074,2075,2076,241],{},"Prerendered Static (",[20,2077,111],{},[257,2079,2022],{"align":232},[257,2081,2025,2082,1192,2084,241],{"align":232},[20,2083,2028],{},[20,2085,2031],{},[257,2087,2088],{"align":232},[20,2089,2036],{},[257,2091,2092],{"align":232},[20,2093,2041],{},[227,2095,2096,2102,2108,2110,2114],{},[257,2097,2098],{"align":232},[25,2099,2075,2100,241],{},[20,2101,111],{},[257,2103,2052,2104,1192,2106,241],{"align":232},[20,2105,1019],{},[20,2107,1027],{},[257,2109,2059],{"align":232},[257,2111,2112],{"align":232},[20,2113,2064],{},[257,2115,2116],{"align":232},[20,2117,1108],{},[16,2119,2120,2121,2123],{},"Zero edge-cache poisoning for external visitors, zero stale cached views or analytics pollution for internal operators—across both SSR and ",[20,2122,1116],{}," routes.",[144,2125],{},[147,2127,2129,2130,2133],{"id":2128},"_4-atomic-nginx-blue-green-cutover-on-a-single-vps-218218-http-200-proof","4. Atomic Nginx Blue-Green Cutover on a Single VPS & ",[20,2131,2132],{},"218/218 HTTP 200"," Proof",[16,2135,2136,2137,2140,2141,2144,2145,574,2147,1142],{},"Even though our four earlier deploys happened during quiet periods and escaped ",[20,2138,2139],{},"502","s, relying on luck during in-place ",[20,2142,2143],{},"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 ",[20,2146,190],{},[20,2148,2139],{},[16,2150,2151],{},"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.",[216,2153,2155],{"id":2154},"_41-dual-slot-architecture-atomic-upstream-swap","4.1. Dual-Slot Architecture & Atomic Upstream Swap",[16,2157,2158],{},"We allocate two symmetric application slots on loopback ports behind the host Nginx reverse proxy:",[548,2160,2161,2174],{},[81,2162,2163,2166,2167,2170,2171],{},[25,2164,2165],{},"Blue slot:"," ",[20,2168,2169],{},"nuxt-app-blue"," listening on ",[20,2172,2173],{},"127.0.0.1:3002",[81,2175,2176,2166,2179,2170,2182],{},[25,2177,2178],{},"Green slot:",[20,2180,2181],{},"nuxt-app-green",[20,2183,2184],{},"127.0.0.1:3012",[16,2186,2187,2188,2191,2192,2195],{},"Nginx never hardcodes the active container port inside the main virtual host block. Instead, it includes a dedicated one-line upstream pointer at ",[20,2189,2190],{},"/srv/reverse-proxy/conf.d/upstream.inc"," and enables ",[20,2193,2194],{},"proxy_next_upstream"," resilience:",[488,2197,2201],{"className":2198,"code":2199,"language":2200,"meta":494,"style":494},"language-nginx shiki shiki-themes github-light github-dark","# /srv/reverse-proxy/conf.d/upstream.inc (swapped atomically)\nserver 127.0.0.1:3012 max_fails=2 fail_timeout=5s;\nserver 127.0.0.1:3002 backup;\n","nginx",[20,2202,2203,2208,2213],{"__ignoreMap":494},[673,2204,2205],{"class":675,"line":676},[673,2206,2207],{},"# /srv/reverse-proxy/conf.d/upstream.inc (swapped atomically)\n",[673,2209,2210],{"class":675,"line":687},[673,2211,2212],{},"server 127.0.0.1:3012 max_fails=2 fail_timeout=5s;\n",[673,2214,2215],{"class":675,"line":695},[673,2216,2217],{},"server 127.0.0.1:3002 backup;\n",[488,2219,2221],{"className":2198,"code":2220,"language":2200,"meta":494,"style":494},"# /srv/reverse-proxy/sites-enabled/inmokang.conf (excerpt)\nupstream nuxt_app_origin {\n    include /srv/reverse-proxy/conf.d/upstream.inc;\n    keepalive 32;\n}\n\nserver {\n    listen 443 ssl http2;\n    server_name inmokang.com;\n\n    location / {\n        proxy_pass http://nuxt_app_origin;\n        proxy_http_version 1.1;\n        proxy_set_header Connection \"\";\n        proxy_set_header Host $host;\n        proxy_set_header CF-Connecting-IP $http_cf_connecting_ip;\n        proxy_set_header X-Real-IP $remote_addr;\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n\n        proxy_next_upstream error timeout invalid_header http_502 http_503;\n        proxy_next_upstream_tries 2;\n        proxy_connect_timeout 3s;\n        proxy_read_timeout 30s;\n    }\n}\n",[20,2222,2223,2228,2233,2238,2243,2247,2251,2256,2261,2266,2270,2275,2280,2285,2290,2295,2300,2305,2310,2314,2319,2324,2329,2334,2339],{"__ignoreMap":494},[673,2224,2225],{"class":675,"line":676},[673,2226,2227],{},"# /srv/reverse-proxy/sites-enabled/inmokang.conf (excerpt)\n",[673,2229,2230],{"class":675,"line":687},[673,2231,2232],{},"upstream nuxt_app_origin {\n",[673,2234,2235],{"class":675,"line":695},[673,2236,2237],{},"    include /srv/reverse-proxy/conf.d/upstream.inc;\n",[673,2239,2240],{"class":675,"line":708},[673,2241,2242],{},"    keepalive 32;\n",[673,2244,2245],{"class":675,"line":719},[673,2246,1840],{},[673,2248,2249],{"class":675,"line":730},[673,2250,1321],{"emptyLinePlaceholder":6},[673,2252,2253],{"class":675,"line":741},[673,2254,2255],{},"server {\n",[673,2257,2258],{"class":675,"line":752},[673,2259,2260],{},"    listen 443 ssl http2;\n",[673,2262,2263],{"class":675,"line":760},[673,2264,2265],{},"    server_name inmokang.com;\n",[673,2267,2268],{"class":675,"line":769},[673,2269,1321],{"emptyLinePlaceholder":6},[673,2271,2272],{"class":675,"line":777},[673,2273,2274],{},"    location / {\n",[673,2276,2277],{"class":675,"line":785},[673,2278,2279],{},"        proxy_pass http://nuxt_app_origin;\n",[673,2281,2282],{"class":675,"line":793},[673,2283,2284],{},"        proxy_http_version 1.1;\n",[673,2286,2287],{"class":675,"line":801},[673,2288,2289],{},"        proxy_set_header Connection \"\";\n",[673,2291,2292],{"class":675,"line":809},[673,2293,2294],{},"        proxy_set_header Host $host;\n",[673,2296,2297],{"class":675,"line":817},[673,2298,2299],{},"        proxy_set_header CF-Connecting-IP $http_cf_connecting_ip;\n",[673,2301,2302],{"class":675,"line":1507},[673,2303,2304],{},"        proxy_set_header X-Real-IP $remote_addr;\n",[673,2306,2307],{"class":675,"line":1540},[673,2308,2309],{},"        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n",[673,2311,2312],{"class":675,"line":1545},[673,2313,1321],{"emptyLinePlaceholder":6},[673,2315,2316],{"class":675,"line":1561},[673,2317,2318],{},"        proxy_next_upstream error timeout invalid_header http_502 http_503;\n",[673,2320,2321],{"class":675,"line":1590},[673,2322,2323],{},"        proxy_next_upstream_tries 2;\n",[673,2325,2326],{"class":675,"line":1617},[673,2327,2328],{},"        proxy_connect_timeout 3s;\n",[673,2330,2331],{"class":675,"line":1644},[673,2332,2333],{},"        proxy_read_timeout 30s;\n",[673,2335,2336],{"class":675,"line":1649},[673,2337,2338],{},"    }\n",[673,2340,2341],{"class":675,"line":1662},[673,2342,1840],{},[16,2344,2345,2346,621],{},"Every deployment executes a deterministic 5-stage state machine in ",[20,2347,2348],{},"/srv/apps/web/deploy-blue-green.sh",[78,2350,2351,2372,2386,2405,2433],{},[81,2352,2353,2356,2357,2359,2360,574,2362,2364,2365,2367,2368,2371],{},[25,2354,2355],{},"Detect active slot & boot standby:"," Inspect ",[20,2358,2190],{},". If ",[20,2361,302],{},[20,2363,2169],{},") is active, build and start ",[20,2366,2181],{}," on ",[20,2369,2370],{},":3012"," (and vice versa). Production traffic never pauses.",[81,2373,2374,2377,2378,2381,2382,2385],{},[25,2375,2376],{},"30-second healthcheck gate:"," Poll ",[20,2379,2380],{},"http://127.0.0.1:${STANDBY_PORT}/"," every second for up to 30 seconds until HTTP ",[20,2383,2384],{},"200"," is returned. If the container fails to boot, abort immediately—the live slot stays untouched.",[81,2387,2388,2391,2392,2394,2395,992,2397,992,2400,992,2403,1142],{},[25,2389,2390],{},"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 + ",[20,2393,534],{}," SQLite caches across core routes (",[20,2396,1082],{},[20,2398,2399],{},"/blog",[20,2401,2402],{},"/en/blog",[20,2404,111],{},[81,2406,2407,2417,2418,2421,2422,2425,2426,2428,2429,2432],{},[25,2408,2409,2410,2413,2414,131],{},"Atomic cutover (",[20,2411,2412],{},"mv -f"," + ",[20,2415,2416],{},"nginx -t && nginx -s reload"," Write the new upstream file to ",[20,2419,2420],{},"upstream.inc.tmp",", atomically replace ",[20,2423,2424],{},"upstream.inc"," via ",[20,2427,2412],{}," (same filesystem rename is atomic on POSIX), validate syntax with ",[20,2430,2431],{},"nginx -t",", and reload Nginx workers gracefully so existing keepalive connections finish cleanly.",[81,2434,2435,2438],{},[25,2436,2437],{},"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.",[488,2440,2444],{"className":2441,"code":2442,"language":2443,"meta":494,"style":494},"language-bash shiki shiki-themes github-light github-dark","#!/usr/bin/env bash\nset -euo pipefail\n\nUPSTREAM_FILE=\"/srv/reverse-proxy/conf.d/upstream.inc\"\nINTERNAL_TEST_IP=\"203.0.113.10\"\n\nif grep -q \"127.0.0.1:3002\" \"$UPSTREAM_FILE\"; then\n  OLD_SLOT=\"nuxt-app-blue\"; OLD_PORT=\"3002\"\n  NEW_SLOT=\"nuxt-app-green\"; NEW_PORT=\"3012\"\nelse\n  OLD_SLOT=\"nuxt-app-green\"; OLD_PORT=\"3012\"\n  NEW_SLOT=\"nuxt-app-blue\"; NEW_PORT=\"3002\"\nfi\n\n# 1. Start standby container on NEW_PORT\ndocker compose -f /srv/apps/web/docker-compose.blue-green.yml up -d --force-recreate \"$NEW_SLOT\"\n\n# 2. Pre-cutover 30s healthcheck gate\nready=0\nfor _ in $(seq 1 30); do\n  if curl -fsS --max-time 2 \"http://127.0.0.1:${NEW_PORT}/\" > /dev/null; then\n    ready=1\n    break\n  fi\n  sleep 1\ndone\n[ \"$ready\" -eq 1 ] || { echo \"Standby healthcheck failed\"; exit 1; }\n\n# 3. SWR & /about internal-IP header self-test + SSR/SQLite warmup\ncurl -fsSI \"http://127.0.0.1:${NEW_PORT}/\" | grep -iq \"s-maxage=300\"\ncurl -fsSI -H \"CF-Connecting-IP: ${INTERNAL_TEST_IP}\" \"http://127.0.0.1:${NEW_PORT}/about\" \\\n  | grep -iq \"CDN-Cache-Control: no-store\"\n\nfor route in \"/\" \"/about\" \"/blog\" \"/en/blog\"; do\n  curl -fsS --max-time 5 \"http://127.0.0.1:${NEW_PORT}${route}\" > /dev/null\ndone\n\n# 4. Atomic upstream swap & graceful Nginx reload\ncat > \"${UPSTREAM_FILE}.tmp\" \u003C\u003CEOF\nserver 127.0.0.1:${NEW_PORT} max_fails=2 fail_timeout=5s;\nserver 127.0.0.1:${OLD_PORT} backup;\nEOF\nmv -f \"${UPSTREAM_FILE}.tmp\" \"$UPSTREAM_FILE\"\nnginx -t && nginx -s reload\n\n# 5. 3-second graceful drain before retiring previous slot\nsleep 3\ndocker stop \"$OLD_SLOT\" && docker rm \"$OLD_SLOT\"\n","bash",[20,2445,2446,2451,2462,2466,2476,2486,2490,2519,2537,2555,2560,2574,2588,2593,2597,2602,2633,2637,2642,2652,2681,2716,2726,2731,2736,2744,2749,2789,2793,2798,2823,2850,2862,2866,2891,2920,2924,2928,2933,2955,2966,2977,2982,3002,3021,3026,3032,3041],{"__ignoreMap":494},[673,2447,2448],{"class":675,"line":676},[673,2449,2450],{"class":1294},"#!/usr/bin/env bash\n",[673,2452,2453,2456,2459],{"class":675,"line":687},[673,2454,2455],{"class":1329},"set",[673,2457,2458],{"class":1329}," -euo",[673,2460,2461],{"class":704}," pipefail\n",[673,2463,2464],{"class":675,"line":695},[673,2465,1321],{"emptyLinePlaceholder":6},[673,2467,2468,2471,2473],{"class":675,"line":708},[673,2469,2470],{"class":683},"UPSTREAM_FILE",[673,2472,1435],{"class":1300},[673,2474,2475],{"class":704},"\"/srv/reverse-proxy/conf.d/upstream.inc\"\n",[673,2477,2478,2481,2483],{"class":675,"line":719},[673,2479,2480],{"class":683},"INTERNAL_TEST_IP",[673,2482,1435],{"class":1300},[673,2484,2485],{"class":704},"\"203.0.113.10\"\n",[673,2487,2488],{"class":675,"line":730},[673,2489,1321],{"emptyLinePlaceholder":6},[673,2491,2492,2495,2498,2501,2504,2507,2510,2513,2516],{"class":675,"line":741},[673,2493,2494],{"class":1300},"if",[673,2496,2497],{"class":1339}," grep",[673,2499,2500],{"class":1329}," -q",[673,2502,2503],{"class":704}," \"127.0.0.1:3002\"",[673,2505,2506],{"class":704}," \"",[673,2508,2509],{"class":683},"$UPSTREAM_FILE",[673,2511,2512],{"class":704},"\"",[673,2514,2515],{"class":683},"; ",[673,2517,2518],{"class":1300},"then\n",[673,2520,2521,2524,2526,2529,2532,2534],{"class":675,"line":752},[673,2522,2523],{"class":683},"  OLD_SLOT",[673,2525,1435],{"class":1300},[673,2527,2528],{"class":704},"\"nuxt-app-blue\"",[673,2530,2531],{"class":683},"; OLD_PORT",[673,2533,1435],{"class":1300},[673,2535,2536],{"class":704},"\"3002\"\n",[673,2538,2539,2542,2544,2547,2550,2552],{"class":675,"line":760},[673,2540,2541],{"class":683},"  NEW_SLOT",[673,2543,1435],{"class":1300},[673,2545,2546],{"class":704},"\"nuxt-app-green\"",[673,2548,2549],{"class":683},"; NEW_PORT",[673,2551,1435],{"class":1300},[673,2553,2554],{"class":704},"\"3012\"\n",[673,2556,2557],{"class":675,"line":769},[673,2558,2559],{"class":1300},"else\n",[673,2561,2562,2564,2566,2568,2570,2572],{"class":675,"line":777},[673,2563,2523],{"class":683},[673,2565,1435],{"class":1300},[673,2567,2546],{"class":704},[673,2569,2531],{"class":683},[673,2571,1435],{"class":1300},[673,2573,2554],{"class":704},[673,2575,2576,2578,2580,2582,2584,2586],{"class":675,"line":785},[673,2577,2541],{"class":683},[673,2579,1435],{"class":1300},[673,2581,2528],{"class":704},[673,2583,2549],{"class":683},[673,2585,1435],{"class":1300},[673,2587,2536],{"class":704},[673,2589,2590],{"class":675,"line":793},[673,2591,2592],{"class":1300},"fi\n",[673,2594,2595],{"class":675,"line":801},[673,2596,1321],{"emptyLinePlaceholder":6},[673,2598,2599],{"class":675,"line":809},[673,2600,2601],{"class":1294},"# 1. Start standby container on NEW_PORT\n",[673,2603,2604,2607,2610,2613,2616,2619,2622,2625,2627,2630],{"class":675,"line":817},[673,2605,2606],{"class":1339},"docker",[673,2608,2609],{"class":704}," compose",[673,2611,2612],{"class":1329}," -f",[673,2614,2615],{"class":704}," /srv/apps/web/docker-compose.blue-green.yml",[673,2617,2618],{"class":704}," up",[673,2620,2621],{"class":1329}," -d",[673,2623,2624],{"class":1329}," --force-recreate",[673,2626,2506],{"class":704},[673,2628,2629],{"class":683},"$NEW_SLOT",[673,2631,2632],{"class":704},"\"\n",[673,2634,2635],{"class":675,"line":1507},[673,2636,1321],{"emptyLinePlaceholder":6},[673,2638,2639],{"class":675,"line":1540},[673,2640,2641],{"class":1294},"# 2. Pre-cutover 30s healthcheck gate\n",[673,2643,2644,2647,2649],{"class":675,"line":1545},[673,2645,2646],{"class":683},"ready",[673,2648,1435],{"class":1300},[673,2650,2651],{"class":704},"0\n",[673,2653,2654,2657,2660,2663,2666,2669,2672,2675,2678],{"class":675,"line":1561},[673,2655,2656],{"class":1300},"for",[673,2658,2659],{"class":683}," _ ",[673,2661,2662],{"class":1300},"in",[673,2664,2665],{"class":683}," $(",[673,2667,2668],{"class":1339},"seq",[673,2670,2671],{"class":1329}," 1",[673,2673,2674],{"class":1329}," 30",[673,2676,2677],{"class":683},"); ",[673,2679,2680],{"class":1300},"do\n",[673,2682,2683,2685,2688,2691,2694,2697,2700,2703,2706,2709,2712,2714],{"class":675,"line":1590},[673,2684,1421],{"class":1300},[673,2686,2687],{"class":1339}," curl",[673,2689,2690],{"class":1329}," -fsS",[673,2692,2693],{"class":1329}," --max-time",[673,2695,2696],{"class":1329}," 2",[673,2698,2699],{"class":704}," \"http://127.0.0.1:${",[673,2701,2702],{"class":683},"NEW_PORT",[673,2704,2705],{"class":704},"}/\"",[673,2707,2708],{"class":1300}," >",[673,2710,2711],{"class":704}," /dev/null",[673,2713,2515],{"class":683},[673,2715,2518],{"class":1300},[673,2717,2718,2721,2723],{"class":675,"line":1617},[673,2719,2720],{"class":683},"    ready",[673,2722,1435],{"class":1300},[673,2724,2725],{"class":704},"1\n",[673,2727,2728],{"class":675,"line":1644},[673,2729,2730],{"class":1300},"    break\n",[673,2732,2733],{"class":675,"line":1649},[673,2734,2735],{"class":1300},"  fi\n",[673,2737,2738,2741],{"class":675,"line":1662},[673,2739,2740],{"class":1339},"  sleep",[673,2742,2743],{"class":1329}," 1\n",[673,2745,2746],{"class":675,"line":1691},[673,2747,2748],{"class":1300},"done\n",[673,2750,2751,2754,2756,2759,2761,2764,2766,2769,2771,2773,2776,2779,2781,2784,2786],{"class":675,"line":1697},[673,2752,2753],{"class":683},"[ ",[673,2755,2512],{"class":704},[673,2757,2758],{"class":683},"$ready",[673,2760,2512],{"class":704},[673,2762,2763],{"class":1300}," -eq",[673,2765,2671],{"class":1329},[673,2767,2768],{"class":683}," ] ",[673,2770,1535],{"class":1300},[673,2772,1304],{"class":683},[673,2774,2775],{"class":1329},"echo",[673,2777,2778],{"class":704}," \"Standby healthcheck failed\"",[673,2780,2515],{"class":683},[673,2782,2783],{"class":1329},"exit",[673,2785,2671],{"class":1329},[673,2787,2788],{"class":683},"; }\n",[673,2790,2791],{"class":675,"line":1702},[673,2792,1321],{"emptyLinePlaceholder":6},[673,2794,2795],{"class":675,"line":1710},[673,2796,2797],{"class":1294},"# 3. SWR & /about internal-IP header self-test + SSR/SQLite warmup\n",[673,2799,2800,2803,2806,2808,2810,2812,2815,2817,2820],{"class":675,"line":1747},[673,2801,2802],{"class":1339},"curl",[673,2804,2805],{"class":1329}," -fsSI",[673,2807,2699],{"class":704},[673,2809,2702],{"class":683},[673,2811,2705],{"class":704},[673,2813,2814],{"class":1300}," |",[673,2816,2497],{"class":1339},[673,2818,2819],{"class":1329}," -iq",[673,2821,2822],{"class":704}," \"s-maxage=300\"\n",[673,2824,2825,2827,2829,2832,2835,2837,2840,2842,2844,2847],{"class":675,"line":1757},[673,2826,2802],{"class":1339},[673,2828,2805],{"class":1329},[673,2830,2831],{"class":1329}," -H",[673,2833,2834],{"class":704}," \"CF-Connecting-IP: ${",[673,2836,2480],{"class":683},[673,2838,2839],{"class":704},"}\"",[673,2841,2699],{"class":704},[673,2843,2702],{"class":683},[673,2845,2846],{"class":704},"}/about\"",[673,2848,2849],{"class":1329}," \\\n",[673,2851,2852,2855,2857,2859],{"class":675,"line":1763},[673,2853,2854],{"class":1300},"  |",[673,2856,2497],{"class":1339},[673,2858,2819],{"class":1329},[673,2860,2861],{"class":704}," \"CDN-Cache-Control: no-store\"\n",[673,2863,2864],{"class":675,"line":1768},[673,2865,1321],{"emptyLinePlaceholder":6},[673,2867,2868,2870,2873,2875,2878,2881,2884,2887,2889],{"class":675,"line":1781},[673,2869,2656],{"class":1300},[673,2871,2872],{"class":683}," route ",[673,2874,2662],{"class":1300},[673,2876,2877],{"class":704}," \"/\"",[673,2879,2880],{"class":704}," \"/about\"",[673,2882,2883],{"class":704}," \"/blog\"",[673,2885,2886],{"class":704}," \"/en/blog\"",[673,2888,2515],{"class":683},[673,2890,2680],{"class":1300},[673,2892,2893,2896,2898,2900,2903,2905,2907,2910,2913,2915,2917],{"class":675,"line":1799},[673,2894,2895],{"class":1339},"  curl",[673,2897,2690],{"class":1329},[673,2899,2693],{"class":1329},[673,2901,2902],{"class":1329}," 5",[673,2904,2699],{"class":704},[673,2906,2702],{"class":683},[673,2908,2909],{"class":704},"}${",[673,2911,2912],{"class":683},"route",[673,2914,2839],{"class":704},[673,2916,2708],{"class":1300},[673,2918,2919],{"class":704}," /dev/null\n",[673,2921,2922],{"class":675,"line":1816},[673,2923,2748],{"class":1300},[673,2925,2926],{"class":675,"line":1832},[673,2927,1321],{"emptyLinePlaceholder":6},[673,2929,2930],{"class":675,"line":1837},[673,2931,2932],{"class":1294},"# 4. Atomic upstream swap & graceful Nginx reload\n",[673,2934,2936,2939,2941,2944,2946,2949,2952],{"class":675,"line":2935},39,[673,2937,2938],{"class":1339},"cat",[673,2940,2708],{"class":1300},[673,2942,2943],{"class":704}," \"${",[673,2945,2470],{"class":683},[673,2947,2948],{"class":704},"}.tmp\"",[673,2950,2951],{"class":1300}," \u003C\u003C",[673,2953,2954],{"class":704},"EOF\n",[673,2956,2958,2961,2963],{"class":675,"line":2957},40,[673,2959,2960],{"class":704},"server 127.0.0.1:${",[673,2962,2702],{"class":683},[673,2964,2965],{"class":704},"} max_fails=2 fail_timeout=5s;\n",[673,2967,2969,2971,2974],{"class":675,"line":2968},41,[673,2970,2960],{"class":704},[673,2972,2973],{"class":683},"OLD_PORT",[673,2975,2976],{"class":704},"} backup;\n",[673,2978,2980],{"class":675,"line":2979},42,[673,2981,2954],{"class":704},[673,2983,2985,2988,2990,2992,2994,2996,2998,3000],{"class":675,"line":2984},43,[673,2986,2987],{"class":1339},"mv",[673,2989,2612],{"class":1329},[673,2991,2943],{"class":704},[673,2993,2470],{"class":683},[673,2995,2948],{"class":704},[673,2997,2506],{"class":704},[673,2999,2509],{"class":683},[673,3001,2632],{"class":704},[673,3003,3005,3007,3010,3013,3015,3018],{"class":675,"line":3004},44,[673,3006,2200],{"class":1339},[673,3008,3009],{"class":1329}," -t",[673,3011,3012],{"class":683}," && ",[673,3014,2200],{"class":1339},[673,3016,3017],{"class":1329}," -s",[673,3019,3020],{"class":704}," reload\n",[673,3022,3024],{"class":675,"line":3023},45,[673,3025,1321],{"emptyLinePlaceholder":6},[673,3027,3029],{"class":675,"line":3028},46,[673,3030,3031],{"class":1294},"# 5. 3-second graceful drain before retiring previous slot\n",[673,3033,3035,3038],{"class":675,"line":3034},47,[673,3036,3037],{"class":1339},"sleep",[673,3039,3040],{"class":1329}," 3\n",[673,3042,3044,3046,3049,3051,3054,3056,3058,3060,3063,3065,3067],{"class":675,"line":3043},48,[673,3045,2606],{"class":1339},[673,3047,3048],{"class":704}," stop",[673,3050,2506],{"class":704},[673,3052,3053],{"class":683},"$OLD_SLOT",[673,3055,2512],{"class":704},[673,3057,3012],{"class":683},[673,3059,2606],{"class":1339},[673,3061,3062],{"class":704}," rm",[673,3064,2506],{"class":704},[673,3066,3053],{"class":683},[673,3068,2632],{"class":704},[216,3070,3072,3073,992,3076,60],{"id":3071},"_42-live-production-proof-218-218-http-200-0-http-502s","4.2. Live Production Proof: ",[20,3074,3075],{},"218 / 218 HTTP 200",[20,3077,59],{},[16,3079,3080,3081,3084,3085,3088],{},"To prove zero downtime under real traffic rather than assuming ",[20,3082,3083],{},"nginx -s reload"," worked, we ran a continuous 1-second external HTTP probe hitting ",[20,3086,3087],{},"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.",[221,3090,3091,3106],{},[224,3092,3093],{},[227,3094,3095,3098,3103],{},[230,3096,3097],{"align":232},"Verification Metric",[230,3099,3100,3101],{"align":232},"In-Place ",[20,3102,42],{},[230,3104,3105],{"align":232},"Atomic Single-VPS Blue-Green Cutover",[252,3107,3108,3123,3141,3163,3178],{},[227,3109,3110,3115,3118],{},[257,3111,3112],{"align":232},[25,3113,3114],{},"Total Continuous Probe Requests (1s interval)",[257,3116,3117],{"align":232},"N/A (5–10s restart gap)",[257,3119,3120],{"align":232},[25,3121,3122],{},"218 requests",[227,3124,3125,3133,3136],{},[257,3126,3127],{"align":232},[25,3128,3129,3130,3132],{},"HTTP ",[20,3131,398],{}," Responses",[257,3134,3135],{"align":232},"Interrupted during recreate",[257,3137,3138],{"align":232},[25,3139,3140],{},"218 / 218 (100.0%)",[227,3142,3143,3156,3159],{},[257,3144,3145],{"align":232},[25,3146,3129,3147,1192,3149,1192,3152,3155],{},[20,3148,2139],{},[20,3150,3151],{},"503",[20,3153,3154],{},"504"," Errors",[257,3157,3158],{"align":232},"Deterministic during cold start",[257,3160,3161],{"align":232},[25,3162,266],{},[227,3164,3165,3170,3173],{},[257,3166,3167],{"align":232},[25,3168,3169],{},"Broken Deploy Blast Radius",[257,3171,3172],{"align":232},"Live site goes down before rollback",[257,3174,3175],{"align":232},[25,3176,3177],{},"0% — aborted at pre-cutover gate",[227,3179,3180,3185,3188],{},[257,3181,3182],{"align":232},[25,3183,3184],{},"Cold-Start TTFB Spike on First User",[257,3186,3187],{"align":232},"First user pays V8 JIT + SQLite init",[257,3189,3190],{"align":232},[25,3191,3192],{},"Absorbed by standby warmup gate",[16,3194,3195,3196,3200],{},"This is the exact same single-VPS zero-downtime deployment discipline we apply across our sibling production web platforms, including ",[210,3197,3199],{"href":3198},"/en/projects/photojob","PhotoJob",", where keeping single-node operational simplicity without sacrificing release reliability matters most.",[216,3202,3204,3205,3207],{"id":3203},"_43-closing-the-observability-loop-eliminating-214-clarity-dead-clicks-with-a-unified-article-lightbox","4.3. Closing the Observability Loop: Eliminating ",[20,3206,130],{}," Clarity Dead Clicks with a Unified Article Lightbox",[16,3209,3210,3211,441,3216,3222],{},"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: ",[25,3212,3213,3215],{},[20,3214,130],{}," Dead Clicks",[25,3217,3218,3221],{},[20,3219,3220],{},"3.6%"," Rage Clicks"," across technical deep-dive posts.",[16,3224,3225,3226,3228,3229,3233,3234,3238],{},"Replaying the Clarity heatmaps made the cause obvious within 30 seconds. Technical posts on ",[20,3227,22],{}," rely heavily on dense architecture schematics, SVG comparison diagrams, and lighting layouts exported from our ",[210,3230,3232],{"href":3231},"https://allutility.net/en/tools/photo-diagram","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 ",[210,3235,3237],{"href":3236},"/en/blog/20261129-hybrid-photo-search-zero-ms-lightbox","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.",[16,3240,3241],{},"We shipped a clean two-part fix alongside the infrastructure hardening:",[548,3243,3244,3294],{},[81,3245,3246,3255,3256,3259,3260,3263,3264,3266,3267,3270,3271,3274,3275,3278,3279,3282,3283,3286,3287,1082,3290,3293],{},[25,3247,3248,3249,2413,3252,131],{},"Unified Inline SVG + Image Lightbox (",[20,3250,3251],{},"useArticleLightbox",[20,3253,3254],{},"ArticleLightboxModal"," Automatically discovers article cover images, prose raster images, and inline ",[20,3257,3258],{},"\u003Csvg>"," diagrams (",[20,3261,3262],{},"> 48px",") while ignoring navigation icons and ad frames. Inline ",[20,3265,3258],{}," nodes are serialized once via ",[20,3268,3269],{},"XMLSerializer"," into a ",[20,3272,3273],{},"WeakMap","-cached ",[20,3276,3277],{},"data:image/svg+xml"," URI, ",[20,3280,3281],{},"/_ipx/"," image optimizer prefixes are unwrapped so gallery keys deduplicate cleanly, and the modal enforces full keyboard accessibility (",[20,3284,3285],{},"Escape"," to close, ",[20,3288,3289],{},"ArrowLeft",[20,3291,3292],{},"ArrowRight"," gallery navigation, body scroll lock, focus trap, and focus restoration back to the triggering element).",[81,3295,3296,3299,3300,3303,3304,3307],{},[25,3297,3298],{},"Strict Visual Affordance Hygiene:"," Applied ",[20,3301,3302],{},"cursor: zoom-in"," exclusively to inspectable article diagrams and images, and locked non-interactive callouts, badges, and metadata rows to ",[20,3305,3306],{},"cursor: default"," so every visual cue promises only interactions that actually exist.",[144,3309],{},[147,3311,3313],{"id":3312},"_5-frequently-asked-questions-faq","5. Frequently Asked Questions (FAQ)",[216,3315,3317],{"id":3316},"q1-why-does-nodejs-throw-a-v8-javascript-heap-out-of-memory-error-near-256-mb-inside-a-512-mb-docker-container","Q1. Why does Node.js throw a V8 JavaScript heap out of memory error near 256 MB inside a 512 MB Docker container?",[16,3319,3320],{},"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.",[216,3322,3324],{"id":3323},"q2-why-do-nuxt-servermiddleware-handlers-fail-to-run-on-prerendered-routes-like-about","Q2. Why do Nuxt server/middleware handlers fail to run on prerendered routes like /about?",[16,3326,3327],{},"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.",[216,3329,3331],{"id":3330},"q3-how-can-you-run-zero-downtime-blue-green-deployments-on-a-single-vps-without-kubernetes","Q3. How can you run zero-downtime Blue-Green deployments on a single VPS without Kubernetes?",[16,3333,3334],{},"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.",[216,3336,3338],{"id":3337},"q4-how-do-you-separate-true-origin-502-errors-from-cloudflare-edge-5xx-noise-during-post-incident-forensics","Q4. How do you separate true origin 502 errors from Cloudflare edge 5xx noise during post-incident forensics?",[16,3340,3341],{},"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.",[144,3343],{},[147,3345,3347],{"id":3346},"wrapping-up-a-production-reliability-checklist-for-single-vps-nuxt-docker-stacks","Wrapping Up: A Production Reliability Checklist for Single-VPS Nuxt + Docker Stacks",[16,3349,3350],{},"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:",[78,3352,3353,3366,3383,3398,3416],{},[81,3354,3355,3358,3359,466,3361,470,3363,3365],{},[25,3356,3357],{},"Correlate 502s across all three layers:"," Never assume HTTP 502s are deploy noise. Cross-check Cloudflare ",[20,3360,168],{},[20,3362,469],{},[20,3364,473],{}," socket codes, and container runtime logs to the exact second.",[81,3367,3368,3371,3372,992,3374,3376,3377,3379,3380,3382],{},[25,3369,3370],{},"Override V8's cgroup 50% default explicitly:"," Pair ",[20,3373,630],{},[20,3375,638],{},", and ",[20,3378,649],{}," so concurrent ",[20,3381,97],{}," SSR traffic cannot starve V8 at 256 MB.",[81,3384,3385,3394,3395,3397],{},[25,3386,3387,3388,3390,3391,3393],{},"Never trust ",[20,3389,115],{}," for ",[20,3392,1116],{}," routes:"," Move request-classification and security/cache header guards into an idempotent utility executed inside Nitro's ",[20,3396,1209],{}," hook (with response-finalization fallback) and mirror exclusions in Cloudflare Cache Rules.",[81,3399,3400,3403,3404,3406,3407,3409,3410,3412,3413,3415],{},[25,3401,3402],{},"Replace in-place restarts with atomic Nginx Blue-Green:"," Run dual loopback slots (",[20,3405,302],{}," ↔ ",[20,3408,2370],{},"), gate every swap behind a 30-second healthcheck + header self-test + SSR/SQLite warmup pass, swap ",[20,3411,2424],{}," atomically via ",[20,3414,2412],{},", reload Nginx, and drain for 3 seconds.",[81,3417,3418,3421],{},[25,3419,3420],{},"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.",[3423,3424,3425],"style",{},"html pre.shiki code .s9eBZ, html code.shiki .s9eBZ{--shiki-default:#22863A;--shiki-dark:#85E89D}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}",{"title":494,"searchDepth":687,"depth":687,"links":3427},[3428,3431,3435,3443,3451,3457],{"id":149,"depth":687,"text":150,"children":3429},[3430],{"id":218,"depth":695,"text":219},{"id":479,"depth":687,"text":480,"children":3432},[3433,3434],{"id":592,"depth":695,"text":593},{"id":825,"depth":695,"text":826},{"id":1004,"depth":687,"text":3436,"children":3437},"3. Closing the Nitro serveStatic Blind Spot on Prerendered Routes (/about)",[3438,3440,3442],{"id":1112,"depth":695,"text":3439},"3.1. Why prerender: true Bypasses server/middleware",{"id":1205,"depth":695,"text":3441},"3.2. Unifying Internal Traffic Detection via Idempotent Utility + Nitro request Hook",{"id":1981,"depth":695,"text":1982},{"id":2128,"depth":687,"text":3444,"children":3445},"4. Atomic Nginx Blue-Green Cutover on a Single VPS & 218/218 HTTP 200 Proof",[3446,3447,3449],{"id":2154,"depth":695,"text":2155},{"id":3071,"depth":695,"text":3448},"4.2. Live Production Proof: 218 / 218 HTTP 200, 0 HTTP 502s",{"id":3203,"depth":695,"text":3450},"4.3. Closing the Observability Loop: Eliminating 21.4% Clarity Dead Clicks with a Unified Article Lightbox",{"id":3312,"depth":687,"text":3313,"children":3452},[3453,3454,3455,3456],{"id":3316,"depth":695,"text":3317},{"id":3323,"depth":695,"text":3324},{"id":3330,"depth":695,"text":3331},{"id":3337,"depth":695,"text":3338},{"id":3346,"depth":687,"text":3347},null,"tech","/images/content-images/blog/20261206-Nuxt-Docker-V8-OOM-Blue-Green-Zero-Downtime/20261206-Nuxt-Docker-V8-OOM-Blue-Green-Zero-Downtime001.jpg","Swiss editorial architecture spec cover summarizing Node.js 20 V8 Old Space expansion from 256 to 512 MB, 768 MB container limit, and 218/218 HTTP 200 live cutover probes","2026-12-06","3-layer forensics exposed a 258 MB Node.js V8 OOM crash behind 16 origin 502s, closed a Nitro prerender cache gap, and proved 218/218 HTTP 200 Blue-Green.","md",[3466,3468,3470,3472],{"question":3467,"answer":3320},"Why does Node.js throw a V8 JavaScript heap out of memory error near 256 MB inside a 512 MB Docker container?",{"question":3469,"answer":3327},"Why do Nuxt server/middleware handlers fail to run on prerendered routes like /about?",{"question":3471,"answer":3334},"How can you run zero-downtime Blue-Green deployments on a single VPS without Kubernetes?",{"question":3473,"answer":3341},"How do you separate true origin 502 errors from Cloudflare edge 5xx noise during post-incident forensics?",{},false,"/en/blog/20261206-nuxt-docker-v8-oom-blue-green-zero-downtime",{"title":5,"description":3463},"Fixing 16 Production 502s in Nuxt + Docker: V8 OOM, Nitro Prerender & Single-VPS Blue-Green | inmokang.com","published","en/blog/20261206-Nuxt-Docker-V8-OOM-Blue-Green-Zero-Downtime",[3482,3483,3484,3485,3486,3487],"Nuxt 4","Docker","Node.js V8","Nginx","Blue-Green Deployment","Observability","epkUlgUwWsAaX5t6hidLecsYrP8VVTgYXv6IiQc3-B4","/blog/20261206-nuxt-docker-v8-oom-blue-green-zero-downtime",[3491,3458],{"title":3492,"path":3493,"stem":3494,"date":3495,"status":3479,"noindex":3475,"children":-1},"Cloudflare Free vs Pro vs Business: Practical Cost, WAF & Rate Limiting Guide (2026)","/en/blog/20261204-cloudflare-free-vs-pro-vs-business-waf-cost-guide","en/blog/20261204-Cloudflare-Free-vs-Pro-vs-Business-WAF-Cost-Guide","2026-12-04",1796527188944]