[{"data":1,"prerenderedAt":2898},["ShallowReactive",2],{"en-blog-detail-/en/blog/20261119-cloudflare-cf-connecting-ip-multi-layer-botnet-defense-2026-12-03":3,"en-blog-linked-project-/en/blog/20261119-cloudflare-cf-connecting-ip-multi-layer-botnet-defense-2026-12-03":2881,"en-blog-ko-counterpart-/en/blog/20261119-cloudflare-cf-connecting-ip-multi-layer-botnet-defense-2026-12-03":2887,"en-blog-surround-/en/blog/20261119-cloudflare-cf-connecting-ip-multi-layer-botnet-defense-2026-12-03":2888},{"id":4,"title":5,"adsEnabled":6,"author":7,"body":8,"buildLogLabel":2849,"category":2850,"coverImage":2851,"coverImageAlt":2852,"date":2853,"description":2854,"extension":2855,"faq":2856,"meta":2865,"navigation":6,"noindex":2866,"path":2867,"project":2868,"promo":2866,"seo":2869,"seoDescription":2870,"seoTitle":2871,"status":2872,"stem":2873,"tags":2874,"__hash__":2880},"enBlog/en/blog/20261119-Cloudflare-CF-Connecting-IP-Multi-Layer-Botnet-Defense.md","Cloudflare CF-Connecting-IP Guide: Restoring Real Client IPs in Nginx & Multi-Layer Botnet Defense",true,"KangSum",{"type":9,"value":10,"toc":2823},"minimark",[11,15,34,53,68,71,76,79,99,151,157,159,166,169,185,195,210,220,319,347,349,353,360,366,373,480,485,488,502,510,538,553,557,564,567,593,595,599,616,620,638,776,787,1018,1022,1036,2183,2194,2523,2537,2539,2543,2556,2564,2581,2587,2616,2641,2645,2648,2712,2719,2721,2725,2729,2740,2744,2760,2764,2787,2791,2819],[12,13,5],"h1",{"id":14},"cloudflare-cf-connecting-ip-guide-restoring-real-client-ips-in-nginx-multi-layer-botnet-defense",[16,17,18,19,24,25,29,30,33],"p",{},"When you run a vertical matching platform like ",[20,21,23],"a",{"href":22},"https://photojob.co.kr","PhotoJob","—connecting commercial photographers, specialized assistants, and rental studios through structured gear and space specifications—automated botnets begin probing your authentication surface regardless of traffic scale. Authentication endpoints handling member accounts, hiring contact details, and studio bookings (",[26,27,28],"code",{},"/api/auth/login",", ",[26,31,32],{},"/api/auth/reset-password",") become continuous targets for external credential-stuffing bots almost immediately after launch.",[16,35,36,37,40,41,48,49,52],{},"The dangerous trap appears when teams try to mitigate those floods by placing Cloudflare's reverse proxy in front of the domain and hastily enabling ",[26,38,39],{},"limit_req"," rate limiting on origin Nginx. If you turn on Nginx rate limiting ",[42,43,44,45],"strong",{},"without restoring the real client IP via ",[26,46,47],{},"CF-Connecting-IP",", your rate limiter does not isolate the attacking botnet—it locks out every legitimate user sharing the same regional Cloudflare edge node, triggering a full-blown ",[42,50,51],{},"Self-DoS"," outage.",[16,54,55,56,59,60,63,64,67],{},"This post dissects how ",[26,57,58],{},"$binary_remote_addr"," gets polluted behind a reverse proxy, explains the IP-spoofing trap of blindly trusting HTTP headers, and walks through the production-verified ",[42,61,62],{},"3-layer Defense-in-Depth architecture"," combining ",[42,65,66],{},"Cloudflare WAF, Nginx Real-IP with path-differentiated HTTP 429 limiting, and a Nuxt 4 (Nitro) authentication guard",".",[69,70],"hr",{},[72,73,75],"h2",{"id":74},"_1-the-incident-trigger-distributed-credential-stuffing-and-the-reverse-proxy-self-dos-trap","1. The Incident Trigger: Distributed Credential Stuffing and the Reverse-Proxy Self-DoS Trap",[16,77,78],{},"A standard early-stage production topology enables Cloudflare's proxied DNS (Orange Cloud) to offload DDoS mitigation and TLS termination to the edge, while running Nginx on the origin host as a reverse proxy in front of a Nuxt application container.",[16,80,81,82,29,85,88,89,91,92,95,96,98],{},"Under calm baseline traffic, this double-proxy stack shows zero outward symptoms. The moment a distributed credential-stuffing botnet (",[26,83,84],{},"203.0.113.10",[26,86,87],{},"203.0.113.45",", and hundreds of rotating nodes) hammers ",[26,90,28],{}," with dozens of ",[26,93,94],{},"POST"," requests per second, however, a naive Nginx ",[26,97,39],{}," rule immediately backfires:",[100,101,102,113,127],"ul",{},[103,104,105,108,109,112],"li",{},[42,106,107],{},"Cascading False-Positive Lockouts:"," Seconds after the attack starts, legitimate users (",[26,110,111],{},"192.0.2.25",") browsing job listings or loading static assets begin experiencing intermittent connection failures alongside the login API.",[103,114,115,118,119,122,123,126],{},[42,116,117],{},"Single-IP Concentration in Origin Logs:"," Inspecting ",[26,120,121],{},"/var/log/nginx/access.log"," on the origin server reveals that requests from completely unrelated ISPs and mobile networks are all logged under a tiny handful of identical IP addresses (",[26,124,125],{},"198.51.100.14",", i.e., Cloudflare edge server IPs).",[103,128,129,136,137,139,140,143,144,147,148,67],{},[42,130,131,132,135],{},"Misleading ",[26,133,134],{},"HTTP 503"," Outage Alerts:"," Because Nginx's ",[26,138,39],{}," module defaults to returning ",[26,141,142],{},"503 Service Temporarily Unavailable"," rather than ",[26,145,146],{},"429 Too Many Requests",", uptime monitors and frontend clients misdiagnose rate limiting as an ",[42,149,150],{},"origin server crash",[16,152,153,154,67],{},"In effect, the defensive wall built to stop malicious traffic uses the attacker's packets as a trigger to sever normal user sessions—a textbook ",[42,155,156],{},"Self-DoS (Self-Inflicted Denial of Service)",[69,158],{},[72,160,162,163,165],{"id":161},"_2-why-legitimate-users-get-blocked-binary_remote_addr-pollution-and-the-header-spoofing-dilemma","2. Why Legitimate Users Get Blocked: ",[26,164,58],{}," Pollution and the Header-Spoofing Dilemma",[16,167,168],{},"The root cause is a mismatch between the OSI Layer 4 (TCP transport) socket peer and the Layer 7 (HTTP application) true originator.",[16,170,171,172,175,176,178,179,67],{},"When traffic flows through Cloudflare's proxy, client browsers never complete a direct TCP handshake with your origin server. Instead, the nearest Cloudflare Anycast edge node terminates the client connection and opens a separate upstream TCP connection to your origin Nginx. Without an explicit real-IP restoration module, the socket peer address Nginx observes—",[26,173,174],{},"$remote_addr",", along with its compact 4-byte binary representation ",[26,177,58],{},"—is permanently pinned to the ",[42,180,181,182,184],{},"Cloudflare edge node's IP (",[26,183,125],{},")",[186,187,193],"pre",{"className":188,"code":190,"language":191,"meta":192},[189],"language-text","# [Origin Nginx log BEFORE Real-IP restoration — RFC 5737 documentation ranges]\n# Both attacker (203.0.113.10) and legitimate user (192.0.2.25) collapse into the same edge socket (198.51.100.14)\nremote_addr=198.51.100.14 cf_ip=203.0.113.10 \"POST /api/auth/login HTTP/1.1\" 503\nremote_addr=198.51.100.14 cf_ip=192.0.2.25  \"GET /studios HTTP/1.1\" 503\n","text","",[26,194,190],{"__ignoreMap":192},[16,196,197,198,201,202,205,206,209],{},"Declaring ",[26,199,200],{},"limit_req_zone $binary_remote_addr"," in this state forces thousands of legitimate visitors routing through a regional PoP (for example, Seoul ",[26,203,204],{},"ICN",") to ",[42,207,208],{},"share a single rate-limit bucket with every attacker hitting that PoP",". The millisecond a bot exhausts the bucket, innocent visitors riding the same edge IP are dropped on the floor.",[16,211,212,213,215,216,219],{},"Yet skipping Nginx configuration and naively reading ",[26,214,47],{}," or ",[26,217,218],{},"X-Forwarded-For"," straight inside application code opens an even more severe vulnerability:",[221,222,223,246],"table",{},[224,225,226],"thead",{},[227,228,229,234,240,243],"tr",{},[230,231,233],"th",{"align":232},"left","Configuration Pattern",[230,235,236,237,239],{"align":232},"Effective ",[26,238,58],{}," Key",[230,241,242],{"align":232},"Impact on Legitimate Users Under Attack",[230,244,245],{"align":232},"Protection Against Header Spoofing",[247,248,249,275,294],"tbody",{},[227,250,251,261,266,272],{},[252,253,254],"td",{"align":232},[42,255,256,257,260],{},"Missing ",[26,258,259],{},"real_ip_header"," (Default)",[252,262,263,264,184],{"align":232},"Cloudflare edge IP (",[26,265,125],{},[252,267,268,271],{"align":232},[42,269,270],{},"Mass collateral lockout (Self-DoS)"," across the same regional PoP",[252,273,274],{"align":232},"Does not read headers, but cannot distinguish real clients",[227,276,277,282,285,288],{},[252,278,279],{"align":232},[42,280,281],{},"Unverified HTTP Header Trust in App",[252,283,284],{"align":232},"Arbitrary header string parsed in app code",[252,286,287],{"align":232},"No edge-IP collateral lockout",[252,289,290,293],{"align":232},[42,291,292],{},"100% rate-limit bypass"," if an attacker hits origin directly with forged headers",[227,295,296,305,310,313],{},[252,297,298],{"align":232},[42,299,300,301,304],{},"Verified CIDR ",[26,302,303],{},"set_real_ip_from"," Restoration",[252,306,307,308,184],{"align":232},"True client IP (",[26,309,84],{},[252,311,312],{"align":232},"Isolates only the attacking IP; zero impact on legitimate users",[252,314,315,318],{"align":232},[42,316,317],{},"Blocks spoofing at the source"," by rewriting only from trusted proxy CIDRs",[320,321,322],"blockquote",{},[16,323,324,327,329,330,332,333,336,337,342,343,346],{},[42,325,326],{},"Key Takeaway:",[26,328,47],{}," and ",[26,331,218],{}," are fundamentally plaintext HTTP request headers. If an attacker discovers your origin IP and sends requests directly—or routes through an untrusted intermediary while injecting a randomized ",[26,334,335],{},"CF-Connecting-IP: 192.0.2.99"," header on every call—any unverified rate limiter becomes completely useless. You must restrict header substitution strictly to ",[42,338,339,340,184],{},"verified Cloudflare proxy CIDR blocks (",[26,341,303],{}," and block direct public access to ports ",[26,344,345],{},"80/443"," at the host or cloud firewall layer.",[69,348],{},[72,350,352],{"id":351},"_3-designing-a-3-layer-defense-in-depth-architecture","3. Designing a 3-Layer Defense-in-Depth Architecture",[16,354,355,356,359],{},"Accurately restoring real client IPs eliminates Self-DoS, but a single IP-based rate limit still fails against modern distributed botnets. ",[42,357,358],{},"Low-and-Slow Credential Stuffing"," attacks harness thousands of residential proxy IPs, sending just 1–2 login requests per minute per IP—slipping effortlessly beneath any per-IP web-server threshold.",[16,361,362,363,365],{},"To close both volumetric and distributed attack vectors in production web stacks like ",[20,364,23],{"href":22},", we separated defensive responsibilities across three independent axes—network edge, reverse proxy, and application runtime:",[16,367,368],{},[369,370],"img",{"alt":371,"src":372},"Comparison diagram contrasting Cloudflare edge-IP Self-DoS when CF-Connecting-IP is omitted against a 3-layer WAF, Nginx HTTP 429, and Nuxt 4 Defense-in-Depth architecture","/images/content-images/blog/20261119-Cloudflare-CF-Connecting-IP-Multi-Layer-Botnet-Defense/20261119-Cloudflare-CF-Connecting-IP-Multi-Layer-Botnet-Defense002.png",[221,374,375,394],{},[224,376,377],{},[227,378,379,382,385,388,391],{},[230,380,381],{"align":232},"Defense Layer",[230,383,384],{"align":232},"Execution Point & Module",[230,386,387],{"align":232},"Primary Discrimination Key",[230,389,390],{"align":232},"Action When Threshold Exceeded",[230,392,393],{"align":232},"Core Security Objective",[247,395,396,418,454],{},[227,397,398,403,406,409,415],{},[252,399,400],{"align":232},[42,401,402],{},"Layer 1: Network Edge",[252,404,405],{"align":232},"Cloudflare WAF Custom Rules",[252,407,408],{"align":232},"Hosting datacenter ASNs · Threat score · Auth URIs",[252,410,411,414],{"align":232},[42,412,413],{},"Managed Challenge"," (non-interactive / JS challenge)",[252,416,417],{"align":232},"Filter automated botnets and cloud-hosted scrapers before reaching origin",[227,419,420,425,434,440,451],{},[252,421,422],{"align":232},[42,423,424],{},"Layer 2: Reverse Proxy",[252,426,427,428,431,432],{"align":232},"Nginx ",[26,429,430],{},"realip"," + ",[26,433,39],{},[252,435,436,437,439],{"align":232},"Restored ",[26,438,58],{}," · Per-route Zones",[252,441,442,431,447,450],{"align":232},[42,443,444],{},[26,445,446],{},"HTTP 429",[26,448,449],{},"Retry-After"," header immediately",[252,452,453],{"align":232},"Contain single-IP bursts, shield browse/static routes, protect Node.js event loop",[227,455,456,461,464,470,477],{},[252,457,458],{"align":232},[42,459,460],{},"Layer 3: App Runtime",[252,462,463],{"align":232},"Nuxt 4 (Nitro) Auth Guard",[252,465,466,469],{"align":232},[26,467,468],{},"(Verified IP + Account Hash)"," sliding window",[252,471,472,476],{"align":232},[42,473,474],{},[26,475,446],{}," + per-account Exponential Backoff",[252,478,479],{"align":232},"Stop distributed multi-IP attacks targeting one account and prevent email enumeration",[481,482,484],"h3",{"id":483},"_31-layer-1-cloudflare-waf-asn-threat-score-managed-challenges-on-auth-routes","3.1. Layer 1 — Cloudflare WAF: ASN & Threat-Score Managed Challenges on Auth Routes",[16,486,487],{},"The first layer filters malicious traffic at the edge before it consumes origin bandwidth or CPU. Hard-blocking entire countries or broad network blocks is risky—it easily disrupts traveling production crew members roaming overseas or legitimate users on corporate VPNs.",[16,489,490,491,494,495,497,498,501],{},"Instead, we target sensitive state-changing routes (",[26,492,493],{},"POST /api/auth/*",") with a ",[42,496,413],{}," whenever traffic originates from cloud-hosting ASNs or carries an elevated threat score. Genuine users in standard browsers pass background verification invisibly, whereas ",[26,499,500],{},"curl","-based or headless credential-stuffing scripts fail immediately at TLS fingerprinting and JavaScript challenge execution.",[481,503,505,506,509],{"id":504},"_32-layer-2-nginx-ngx_http_realip_module-restoration-differentiated-http-429-zones","3.2. Layer 2 — Nginx ",[26,507,508],{},"ngx_http_realip_module"," Restoration & Differentiated HTTP 429 Zones",[16,511,512,513,515,516,518,519,521,522,524,525,531,532,67],{},"Origin Nginx enforces two non-negotiable rules. First, ",[26,514,508],{}," rewrites ",[26,517,58],{}," from ",[26,520,47],{}," exclusively for packets arriving from trusted proxy ranges (",[26,523,303],{},"). Second, instead of cramming all routes into one shared bucket, we split traffic into a ",[42,526,527,528,184],{},"strict authentication zone (",[26,529,530],{},"auth_limit"," and a ",[42,533,534,535,184],{},"general SSR/API browsing zone (",[26,536,537],{},"general_limit",[16,539,540,541,544,545,548,549,552],{},"Because photo-industry job boards and studio galleries trigger rapid filter changes and high-resolution thumbnail fetches, general browse routes need generous burst headroom (",[26,542,543],{},"burst=30 nodelay","), while login endpoints stay locked to roughly 5 requests per minute per IP. Explicitly declaring ",[26,546,547],{},"limit_req_status 429;"," eliminates the default ",[26,550,551],{},"503"," false-outage signal.",[481,554,556],{"id":555},"_33-layer-3-nuxt-4-nitro-account-ip-sliding-window-and-exponential-backoff","3.3. Layer 3 — Nuxt 4 (Nitro) Account + IP Sliding Window and Exponential Backoff",[16,558,559,560,563],{},"The third layer introduces domain awareness inside Nuxt 4's Nitro server engine. Nginx has no visibility into the JSON ",[26,561,562],{},"email"," field inside an HTTP request body or whether a password check succeeded. If a botnet deploys 500 distinct proxy IPs to try one password each against a single studio account, Layer 2 will rightfully allow every single packet through.",[16,565,566],{},"To defeat distributed targeting, the Nitro authentication handler tracks two coordinated counters:",[100,568,569,579],{},[103,570,571,578],{},[42,572,573,574,577],{},"Composite ",[26,575,576],{},"(Verified IP + Normalized Account Key)"," Limit:"," Immediately isolates repeated failures from one client against a specific account.",[103,580,581,584,585,588,589,592],{},[42,582,583],{},"Per-Account Exponential Backoff:"," As failed logins accumulate against the same account across arbitrary IPs, retry cooldowns scale exponentially (",[26,586,587],{},"4s → 8s → 16s → ... → capped at 300s","). Choosing bounded time-based backoff over permanent Hard Lockout also prevents ",[42,590,591],{},"Account Lockout DoS",", where an attacker deliberately trips failed attempts to freeze a legitimate customer out of their workspace.",[69,594],{},[72,596,598],{"id":597},"_4-production-implementation-nginx-real-ip-config-nuxt-4-auth-guard-middleware","4. Production Implementation: Nginx Real-IP Config & Nuxt 4 Auth Guard Middleware",[16,600,601,602,67],{},"Below are production-ready Nginx configurations and Nuxt 4 (Nitro) server utilities. All IP prefixes follow the ",[42,603,604,605,29,608,29,611,29,613,184],{},"RFC 5737 / RFC 3849 documentation ranges (",[26,606,607],{},"198.51.100.0/24",[26,609,610],{},"192.0.2.0/24",[26,612,84],{},[26,614,615],{},"2001:db8::/32",[481,617,619],{"id":618},"_41-nginx-real-ip-restoration-and-per-route-rate-limiting","4.1. Nginx Real-IP Restoration and Per-Route Rate Limiting",[16,621,622,623,626,627,629,630,633,634,637],{},"First, create ",[26,624,625],{},"/etc/nginx/conf.d/cloudflare-realip.conf"," to whitelist Cloudflare's published IPv4/IPv6 CIDR blocks and enable ",[26,628,47],{}," extraction. In production, sync Cloudflare's official IP lists periodically via a ",[26,631,632],{},"systemd"," timer that runs ",[26,635,636],{},"nginx -t"," before reloading cleanly.",[186,639,643],{"className":640,"code":641,"language":642,"meta":192,"style":192},"language-nginx shiki shiki-themes github-light github-dark","# /etc/nginx/conf.d/cloudflare-realip.conf\n# Sync Cloudflare's official published IPv4/IPv6 CIDR lists in production.\n# (Ranges below are RFC 5737 / RFC 3849 documentation examples.)\nset_real_ip_from 198.51.100.0/24;\nset_real_ip_from 192.0.2.0/24;\nset_real_ip_from 2001:db8::/32;\n\nreal_ip_header CF-Connecting-IP;\nreal_ip_recursive on;\n\n# Separate shared-memory rate-limit zones keyed by restored 4-byte binary client IP\nlimit_req_zone $binary_remote_addr zone=auth_limit:10m rate=5r/m;\nlimit_req_zone $binary_remote_addr zone=general_limit:10m rate=15r/s;\n\n# Enforce standard HTTP 429 instead of Nginx's default 503\nlimit_req_status 429;\nlimit_conn_status 429;\n\n# Log both restored client IP ($remote_addr) and upstream edge socket ($realip_remote_addr) for audits\nlog_format security_audit '$remote_addr (edge:$realip_remote_addr) - [$time_local] '\n                          '\"$request\" $status $body_bytes_sent '\n                          '\"$http_user_agent\" cf_ray=\"$http_cf_ray\"';\n","nginx",[26,644,645,653,659,665,671,677,683,689,695,701,706,712,718,724,729,735,741,747,752,758,764,770],{"__ignoreMap":192},[646,647,650],"span",{"class":648,"line":649},"line",1,[646,651,652],{},"# /etc/nginx/conf.d/cloudflare-realip.conf\n",[646,654,656],{"class":648,"line":655},2,[646,657,658],{},"# Sync Cloudflare's official published IPv4/IPv6 CIDR lists in production.\n",[646,660,662],{"class":648,"line":661},3,[646,663,664],{},"# (Ranges below are RFC 5737 / RFC 3849 documentation examples.)\n",[646,666,668],{"class":648,"line":667},4,[646,669,670],{},"set_real_ip_from 198.51.100.0/24;\n",[646,672,674],{"class":648,"line":673},5,[646,675,676],{},"set_real_ip_from 192.0.2.0/24;\n",[646,678,680],{"class":648,"line":679},6,[646,681,682],{},"set_real_ip_from 2001:db8::/32;\n",[646,684,686],{"class":648,"line":685},7,[646,687,688],{"emptyLinePlaceholder":6},"\n",[646,690,692],{"class":648,"line":691},8,[646,693,694],{},"real_ip_header CF-Connecting-IP;\n",[646,696,698],{"class":648,"line":697},9,[646,699,700],{},"real_ip_recursive on;\n",[646,702,704],{"class":648,"line":703},10,[646,705,688],{"emptyLinePlaceholder":6},[646,707,709],{"class":648,"line":708},11,[646,710,711],{},"# Separate shared-memory rate-limit zones keyed by restored 4-byte binary client IP\n",[646,713,715],{"class":648,"line":714},12,[646,716,717],{},"limit_req_zone $binary_remote_addr zone=auth_limit:10m rate=5r/m;\n",[646,719,721],{"class":648,"line":720},13,[646,722,723],{},"limit_req_zone $binary_remote_addr zone=general_limit:10m rate=15r/s;\n",[646,725,727],{"class":648,"line":726},14,[646,728,688],{"emptyLinePlaceholder":6},[646,730,732],{"class":648,"line":731},15,[646,733,734],{},"# Enforce standard HTTP 429 instead of Nginx's default 503\n",[646,736,738],{"class":648,"line":737},16,[646,739,740],{},"limit_req_status 429;\n",[646,742,744],{"class":648,"line":743},17,[646,745,746],{},"limit_conn_status 429;\n",[646,748,750],{"class":648,"line":749},18,[646,751,688],{"emptyLinePlaceholder":6},[646,753,755],{"class":648,"line":754},19,[646,756,757],{},"# Log both restored client IP ($remote_addr) and upstream edge socket ($realip_remote_addr) for audits\n",[646,759,761],{"class":648,"line":760},20,[646,762,763],{},"log_format security_audit '$remote_addr (edge:$realip_remote_addr) - [$time_local] '\n",[646,765,767],{"class":648,"line":766},21,[646,768,769],{},"                          '\"$request\" $status $body_bytes_sent '\n",[646,771,773],{"class":648,"line":772},22,[646,774,775],{},"                          '\"$http_user_agent\" cf_ray=\"$http_cf_ray\"';\n",[16,777,778,779,782,783,786],{},"Next, wire separate bucket policies and a structured JSON ",[26,780,781],{},"429"," response inside your virtual host configuration (",[26,784,785],{},"/etc/nginx/sites-available/photojob.conf","):",[186,788,790],{"className":640,"code":789,"language":642,"meta":192,"style":192},"# /etc/nginx/sites-available/photojob.conf\nupstream photojob_nuxt_upstream {\n    server unix:/run/photojob/nitro.sock;\n    keepalive 32;\n}\n\nserver {\n    listen 443 ssl http2;\n    server_name photojob.co.kr;\n\n    access_log /var/log/nginx/photojob.access.log security_audit;\n\n    # Return explicit Retry-After header and structured JSON payload on HTTP 429\n    error_page 429 = @rate_limited;\n    location @rate_limited {\n        default_type application/json;\n        add_header Retry-After 60 always;\n        return 429 '{\"statusCode\":429,\"message\":\"Too many requests. Please try again shortly.\"}';\n    }\n\n    # Sensitive Auth APIs: 5 req/min with a tight burst (3) to halt credential stuffing at Layer 2\n    location ~ ^/api/auth/(login|reset-password|register)$ {\n        limit_req zone=auth_limit burst=3 nodelay;\n\n        proxy_pass http://photojob_nuxt_upstream;\n        proxy_http_version 1.1;\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n        proxy_set_header X-Forwarded-Proto $scheme;\n    }\n\n    # General SSR pages & search APIs: generous burst to prevent false positives during browsing\n    location / {\n        limit_req zone=general_limit burst=30 nodelay;\n\n        proxy_pass http://photojob_nuxt_upstream;\n        proxy_http_version 1.1;\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n        proxy_set_header X-Forwarded-Proto $scheme;\n    }\n}\n",[26,791,792,797,802,807,812,817,821,826,831,836,840,845,849,854,859,864,869,874,879,884,888,893,898,904,909,915,921,927,933,939,945,950,955,961,967,973,978,983,988,993,998,1003,1008,1013],{"__ignoreMap":192},[646,793,794],{"class":648,"line":649},[646,795,796],{},"# /etc/nginx/sites-available/photojob.conf\n",[646,798,799],{"class":648,"line":655},[646,800,801],{},"upstream photojob_nuxt_upstream {\n",[646,803,804],{"class":648,"line":661},[646,805,806],{},"    server unix:/run/photojob/nitro.sock;\n",[646,808,809],{"class":648,"line":667},[646,810,811],{},"    keepalive 32;\n",[646,813,814],{"class":648,"line":673},[646,815,816],{},"}\n",[646,818,819],{"class":648,"line":679},[646,820,688],{"emptyLinePlaceholder":6},[646,822,823],{"class":648,"line":685},[646,824,825],{},"server {\n",[646,827,828],{"class":648,"line":691},[646,829,830],{},"    listen 443 ssl http2;\n",[646,832,833],{"class":648,"line":697},[646,834,835],{},"    server_name photojob.co.kr;\n",[646,837,838],{"class":648,"line":703},[646,839,688],{"emptyLinePlaceholder":6},[646,841,842],{"class":648,"line":708},[646,843,844],{},"    access_log /var/log/nginx/photojob.access.log security_audit;\n",[646,846,847],{"class":648,"line":714},[646,848,688],{"emptyLinePlaceholder":6},[646,850,851],{"class":648,"line":720},[646,852,853],{},"    # Return explicit Retry-After header and structured JSON payload on HTTP 429\n",[646,855,856],{"class":648,"line":726},[646,857,858],{},"    error_page 429 = @rate_limited;\n",[646,860,861],{"class":648,"line":731},[646,862,863],{},"    location @rate_limited {\n",[646,865,866],{"class":648,"line":737},[646,867,868],{},"        default_type application/json;\n",[646,870,871],{"class":648,"line":743},[646,872,873],{},"        add_header Retry-After 60 always;\n",[646,875,876],{"class":648,"line":749},[646,877,878],{},"        return 429 '{\"statusCode\":429,\"message\":\"Too many requests. Please try again shortly.\"}';\n",[646,880,881],{"class":648,"line":754},[646,882,883],{},"    }\n",[646,885,886],{"class":648,"line":760},[646,887,688],{"emptyLinePlaceholder":6},[646,889,890],{"class":648,"line":766},[646,891,892],{},"    # Sensitive Auth APIs: 5 req/min with a tight burst (3) to halt credential stuffing at Layer 2\n",[646,894,895],{"class":648,"line":772},[646,896,897],{},"    location ~ ^/api/auth/(login|reset-password|register)$ {\n",[646,899,901],{"class":648,"line":900},23,[646,902,903],{},"        limit_req zone=auth_limit burst=3 nodelay;\n",[646,905,907],{"class":648,"line":906},24,[646,908,688],{"emptyLinePlaceholder":6},[646,910,912],{"class":648,"line":911},25,[646,913,914],{},"        proxy_pass http://photojob_nuxt_upstream;\n",[646,916,918],{"class":648,"line":917},26,[646,919,920],{},"        proxy_http_version 1.1;\n",[646,922,924],{"class":648,"line":923},27,[646,925,926],{},"        proxy_set_header Host $host;\n",[646,928,930],{"class":648,"line":929},28,[646,931,932],{},"        proxy_set_header X-Real-IP $remote_addr;\n",[646,934,936],{"class":648,"line":935},29,[646,937,938],{},"        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n",[646,940,942],{"class":648,"line":941},30,[646,943,944],{},"        proxy_set_header X-Forwarded-Proto $scheme;\n",[646,946,948],{"class":648,"line":947},31,[646,949,883],{},[646,951,953],{"class":648,"line":952},32,[646,954,688],{"emptyLinePlaceholder":6},[646,956,958],{"class":648,"line":957},33,[646,959,960],{},"    # General SSR pages & search APIs: generous burst to prevent false positives during browsing\n",[646,962,964],{"class":648,"line":963},34,[646,965,966],{},"    location / {\n",[646,968,970],{"class":648,"line":969},35,[646,971,972],{},"        limit_req zone=general_limit burst=30 nodelay;\n",[646,974,976],{"class":648,"line":975},36,[646,977,688],{"emptyLinePlaceholder":6},[646,979,981],{"class":648,"line":980},37,[646,982,914],{},[646,984,986],{"class":648,"line":985},38,[646,987,920],{},[646,989,991],{"class":648,"line":990},39,[646,992,926],{},[646,994,996],{"class":648,"line":995},40,[646,997,932],{},[646,999,1001],{"class":648,"line":1000},41,[646,1002,938],{},[646,1004,1006],{"class":648,"line":1005},42,[646,1007,944],{},[646,1009,1011],{"class":648,"line":1010},43,[646,1012,883],{},[646,1014,1016],{"class":648,"line":1015},44,[646,1017,816],{},[481,1019,1021],{"id":1020},"_42-nuxt-4-nitro-sliding-window-exponential-backoff-auth-guard","4.2. Nuxt 4 (Nitro) Sliding-Window & Exponential Backoff Auth Guard",[16,1023,1024,1025,1027,1028,1031,1032,1035],{},"Because origin Nginx has already verified and injected the restored ",[26,1026,174],{}," into ",[26,1029,1030],{},"X-Real-IP",", the Nuxt 4 server route reads only that trusted internal header rather than raw client-controllable headers. We also perform constant-time dummy hash verification for non-existent emails to eliminate ",[42,1033,1034],{},"Timing Side-Channel"," account enumeration.",[186,1037,1041],{"className":1038,"code":1039,"language":1040,"meta":192,"style":192},"language-ts shiki shiki-themes github-light github-dark","// /app/server/utils/authRateGuard.ts\nimport { createHash } from 'node:crypto'\nimport type { H3Event } from 'h3'\nimport { createError, getRequestHeader, setResponseHeader } from 'h3'\n\ninterface AttemptRecord {\n  failures: number\n  windowStartMs: number\n  lockedUntilMs: number\n}\n\nconst WINDOW_MS = 10 * 60 * 1000 // 10-minute sliding window\nconst BASE_LOCK_SEC = 4\nconst MAX_LOCK_SEC = 300\nconst THRESHOLD = 5\n\n// In-memory store for single-node deployments; swap to Redis via unstorage for multi-container clusters\nconst attemptStore = new Map\u003Cstring, AttemptRecord>()\n\nfunction hashKey(raw: string): string {\n  return createHash('sha256').update(raw.trim().toLowerCase()).digest('hex').slice(0, 24)\n}\n\nexport function extractVerifiedClientIp(event: H3Event): string {\n  // Trust only X-Real-IP injected by origin Nginx after ngx_http_realip_module validation\n  return getRequestHeader(event, 'x-real-ip') || event.node.req.socket.remoteAddress || 'unknown'\n}\n\nexport function assertLoginAllowed(event: H3Event, email: string): { ipKey: string; acctKey: string } {\n  const now = Date.now()\n  const clientIp = extractVerifiedClientIp(event)\n  const normalizedAcct = hashKey(email)\n\n  const ipKey = `auth:ip-acct:${clientIp}:${normalizedAcct}`\n  const acctKey = `auth:acct:${normalizedAcct}`\n\n  for (const key of [ipKey, acctKey]) {\n    const rec = attemptStore.get(key)\n    if (rec && rec.lockedUntilMs > now) {\n      const retryAfterSec = Math.ceil((rec.lockedUntilMs - now) / 1000)\n      setResponseHeader(event, 'Retry-After', retryAfterSec)\n      throw createError({\n        statusCode: 429,\n        statusMessage: 'Too Many Requests',\n        message: `Login attempts are temporarily throttled. Please retry in ${retryAfterSec} seconds.`,\n      })\n    }\n  }\n\n  return { ipKey, acctKey }\n}\n\nexport function recordLoginResult(keys: { ipKey: string; acctKey: string }, succeeded: boolean): void {\n  if (succeeded) {\n    attemptStore.delete(keys.ipKey)\n    attemptStore.delete(keys.acctKey)\n    return\n  }\n\n  const now = Date.now()\n  for (const [idx, key] of [keys.ipKey, keys.acctKey].entries()) {\n    const prev = attemptStore.get(key)\n    const inWindow = prev && (now - prev.windowStartMs) \u003C WINDOW_MS\n    const failures = inWindow ? prev.failures + 1 : 1\n    // Global account key (idx === 1) uses a slightly wider threshold (THRESHOLD + 3) against distributed bots\n    const limit = idx === 0 ? THRESHOLD : THRESHOLD + 3\n\n    let lockedUntilMs = 0\n    if (failures >= limit) {\n      const expSec = Math.min(BASE_LOCK_SEC * (2 ** (failures - limit)), MAX_LOCK_SEC)\n      lockedUntilMs = now + expSec * 1000\n    }\n\n    attemptStore.set(key, {\n      failures,\n      windowStartMs: inWindow ? prev.windowStartMs : now,\n      lockedUntilMs,\n    })\n  }\n}\n","ts",[26,1042,1043,1049,1066,1081,1092,1096,1108,1121,1130,1139,1143,1147,1175,1187,1199,1211,1215,1220,1249,1253,1280,1340,1344,1348,1377,1382,1409,1413,1417,1469,1488,1502,1516,1520,1544,1560,1564,1583,1602,1622,1654,1667,1678,1688,1698,1715,1721,1726,1732,1737,1745,1750,1755,1808,1817,1829,1839,1845,1850,1855,1870,1905,1921,1949,1980,1986,2020,2025,2040,2054,2096,2118,2123,2128,2139,2145,2161,2167,2173,2178],{"__ignoreMap":192},[646,1044,1045],{"class":648,"line":649},[646,1046,1048],{"class":1047},"sJ8bj","// /app/server/utils/authRateGuard.ts\n",[646,1050,1051,1055,1059,1062],{"class":648,"line":655},[646,1052,1054],{"class":1053},"szBVR","import",[646,1056,1058],{"class":1057},"sVt8B"," { createHash } ",[646,1060,1061],{"class":1053},"from",[646,1063,1065],{"class":1064},"sZZnC"," 'node:crypto'\n",[646,1067,1068,1070,1073,1076,1078],{"class":648,"line":661},[646,1069,1054],{"class":1053},[646,1071,1072],{"class":1053}," type",[646,1074,1075],{"class":1057}," { H3Event } ",[646,1077,1061],{"class":1053},[646,1079,1080],{"class":1064}," 'h3'\n",[646,1082,1083,1085,1088,1090],{"class":648,"line":667},[646,1084,1054],{"class":1053},[646,1086,1087],{"class":1057}," { createError, getRequestHeader, setResponseHeader } ",[646,1089,1061],{"class":1053},[646,1091,1080],{"class":1064},[646,1093,1094],{"class":648,"line":673},[646,1095,688],{"emptyLinePlaceholder":6},[646,1097,1098,1101,1105],{"class":648,"line":679},[646,1099,1100],{"class":1053},"interface",[646,1102,1104],{"class":1103},"sScJk"," AttemptRecord",[646,1106,1107],{"class":1057}," {\n",[646,1109,1110,1114,1117],{"class":648,"line":685},[646,1111,1113],{"class":1112},"s4XuR","  failures",[646,1115,1116],{"class":1053},":",[646,1118,1120],{"class":1119},"sj4cs"," number\n",[646,1122,1123,1126,1128],{"class":648,"line":691},[646,1124,1125],{"class":1112},"  windowStartMs",[646,1127,1116],{"class":1053},[646,1129,1120],{"class":1119},[646,1131,1132,1135,1137],{"class":648,"line":697},[646,1133,1134],{"class":1112},"  lockedUntilMs",[646,1136,1116],{"class":1053},[646,1138,1120],{"class":1119},[646,1140,1141],{"class":648,"line":703},[646,1142,816],{"class":1057},[646,1144,1145],{"class":648,"line":708},[646,1146,688],{"emptyLinePlaceholder":6},[646,1148,1149,1152,1155,1158,1161,1164,1167,1169,1172],{"class":648,"line":714},[646,1150,1151],{"class":1053},"const",[646,1153,1154],{"class":1119}," WINDOW_MS",[646,1156,1157],{"class":1053}," =",[646,1159,1160],{"class":1119}," 10",[646,1162,1163],{"class":1053}," *",[646,1165,1166],{"class":1119}," 60",[646,1168,1163],{"class":1053},[646,1170,1171],{"class":1119}," 1000",[646,1173,1174],{"class":1047}," // 10-minute sliding window\n",[646,1176,1177,1179,1182,1184],{"class":648,"line":720},[646,1178,1151],{"class":1053},[646,1180,1181],{"class":1119}," BASE_LOCK_SEC",[646,1183,1157],{"class":1053},[646,1185,1186],{"class":1119}," 4\n",[646,1188,1189,1191,1194,1196],{"class":648,"line":726},[646,1190,1151],{"class":1053},[646,1192,1193],{"class":1119}," MAX_LOCK_SEC",[646,1195,1157],{"class":1053},[646,1197,1198],{"class":1119}," 300\n",[646,1200,1201,1203,1206,1208],{"class":648,"line":731},[646,1202,1151],{"class":1053},[646,1204,1205],{"class":1119}," THRESHOLD",[646,1207,1157],{"class":1053},[646,1209,1210],{"class":1119}," 5\n",[646,1212,1213],{"class":648,"line":737},[646,1214,688],{"emptyLinePlaceholder":6},[646,1216,1217],{"class":648,"line":743},[646,1218,1219],{"class":1047},"// In-memory store for single-node deployments; swap to Redis via unstorage for multi-container clusters\n",[646,1221,1222,1224,1227,1229,1232,1235,1238,1241,1243,1246],{"class":648,"line":749},[646,1223,1151],{"class":1053},[646,1225,1226],{"class":1119}," attemptStore",[646,1228,1157],{"class":1053},[646,1230,1231],{"class":1053}," new",[646,1233,1234],{"class":1103}," Map",[646,1236,1237],{"class":1057},"\u003C",[646,1239,1240],{"class":1119},"string",[646,1242,29],{"class":1057},[646,1244,1245],{"class":1103},"AttemptRecord",[646,1247,1248],{"class":1057},">()\n",[646,1250,1251],{"class":648,"line":754},[646,1252,688],{"emptyLinePlaceholder":6},[646,1254,1255,1258,1261,1264,1267,1269,1272,1274,1276,1278],{"class":648,"line":760},[646,1256,1257],{"class":1053},"function",[646,1259,1260],{"class":1103}," hashKey",[646,1262,1263],{"class":1057},"(",[646,1265,1266],{"class":1112},"raw",[646,1268,1116],{"class":1053},[646,1270,1271],{"class":1119}," string",[646,1273,184],{"class":1057},[646,1275,1116],{"class":1053},[646,1277,1271],{"class":1119},[646,1279,1107],{"class":1057},[646,1281,1282,1285,1288,1290,1293,1296,1299,1302,1305,1308,1311,1314,1317,1319,1322,1324,1327,1329,1332,1334,1337],{"class":648,"line":766},[646,1283,1284],{"class":1053},"  return",[646,1286,1287],{"class":1103}," createHash",[646,1289,1263],{"class":1057},[646,1291,1292],{"class":1064},"'sha256'",[646,1294,1295],{"class":1057},").",[646,1297,1298],{"class":1103},"update",[646,1300,1301],{"class":1057},"(raw.",[646,1303,1304],{"class":1103},"trim",[646,1306,1307],{"class":1057},"().",[646,1309,1310],{"class":1103},"toLowerCase",[646,1312,1313],{"class":1057},"()).",[646,1315,1316],{"class":1103},"digest",[646,1318,1263],{"class":1057},[646,1320,1321],{"class":1064},"'hex'",[646,1323,1295],{"class":1057},[646,1325,1326],{"class":1103},"slice",[646,1328,1263],{"class":1057},[646,1330,1331],{"class":1119},"0",[646,1333,29],{"class":1057},[646,1335,1336],{"class":1119},"24",[646,1338,1339],{"class":1057},")\n",[646,1341,1342],{"class":648,"line":772},[646,1343,816],{"class":1057},[646,1345,1346],{"class":648,"line":900},[646,1347,688],{"emptyLinePlaceholder":6},[646,1349,1350,1353,1356,1359,1361,1364,1366,1369,1371,1373,1375],{"class":648,"line":906},[646,1351,1352],{"class":1053},"export",[646,1354,1355],{"class":1053}," function",[646,1357,1358],{"class":1103}," extractVerifiedClientIp",[646,1360,1263],{"class":1057},[646,1362,1363],{"class":1112},"event",[646,1365,1116],{"class":1053},[646,1367,1368],{"class":1103}," H3Event",[646,1370,184],{"class":1057},[646,1372,1116],{"class":1053},[646,1374,1271],{"class":1119},[646,1376,1107],{"class":1057},[646,1378,1379],{"class":648,"line":911},[646,1380,1381],{"class":1047},"  // Trust only X-Real-IP injected by origin Nginx after ngx_http_realip_module validation\n",[646,1383,1384,1386,1389,1392,1395,1398,1401,1404,1406],{"class":648,"line":917},[646,1385,1284],{"class":1053},[646,1387,1388],{"class":1103}," getRequestHeader",[646,1390,1391],{"class":1057},"(event, ",[646,1393,1394],{"class":1064},"'x-real-ip'",[646,1396,1397],{"class":1057},") ",[646,1399,1400],{"class":1053},"||",[646,1402,1403],{"class":1057}," event.node.req.socket.remoteAddress ",[646,1405,1400],{"class":1053},[646,1407,1408],{"class":1064}," 'unknown'\n",[646,1410,1411],{"class":648,"line":923},[646,1412,816],{"class":1057},[646,1414,1415],{"class":648,"line":929},[646,1416,688],{"emptyLinePlaceholder":6},[646,1418,1419,1421,1423,1426,1428,1430,1432,1434,1436,1438,1440,1442,1444,1446,1449,1452,1454,1456,1459,1462,1464,1466],{"class":648,"line":935},[646,1420,1352],{"class":1053},[646,1422,1355],{"class":1053},[646,1424,1425],{"class":1103}," assertLoginAllowed",[646,1427,1263],{"class":1057},[646,1429,1363],{"class":1112},[646,1431,1116],{"class":1053},[646,1433,1368],{"class":1103},[646,1435,29],{"class":1057},[646,1437,562],{"class":1112},[646,1439,1116],{"class":1053},[646,1441,1271],{"class":1119},[646,1443,184],{"class":1057},[646,1445,1116],{"class":1053},[646,1447,1448],{"class":1057}," { ",[646,1450,1451],{"class":1112},"ipKey",[646,1453,1116],{"class":1053},[646,1455,1271],{"class":1119},[646,1457,1458],{"class":1057},"; ",[646,1460,1461],{"class":1112},"acctKey",[646,1463,1116],{"class":1053},[646,1465,1271],{"class":1119},[646,1467,1468],{"class":1057}," } {\n",[646,1470,1471,1474,1477,1479,1482,1485],{"class":648,"line":941},[646,1472,1473],{"class":1053},"  const",[646,1475,1476],{"class":1119}," now",[646,1478,1157],{"class":1053},[646,1480,1481],{"class":1057}," Date.",[646,1483,1484],{"class":1103},"now",[646,1486,1487],{"class":1057},"()\n",[646,1489,1490,1492,1495,1497,1499],{"class":648,"line":947},[646,1491,1473],{"class":1053},[646,1493,1494],{"class":1119}," clientIp",[646,1496,1157],{"class":1053},[646,1498,1358],{"class":1103},[646,1500,1501],{"class":1057},"(event)\n",[646,1503,1504,1506,1509,1511,1513],{"class":648,"line":952},[646,1505,1473],{"class":1053},[646,1507,1508],{"class":1119}," normalizedAcct",[646,1510,1157],{"class":1053},[646,1512,1260],{"class":1103},[646,1514,1515],{"class":1057},"(email)\n",[646,1517,1518],{"class":648,"line":957},[646,1519,688],{"emptyLinePlaceholder":6},[646,1521,1522,1524,1527,1529,1532,1535,1538,1541],{"class":648,"line":963},[646,1523,1473],{"class":1053},[646,1525,1526],{"class":1119}," ipKey",[646,1528,1157],{"class":1053},[646,1530,1531],{"class":1064}," `auth:ip-acct:${",[646,1533,1534],{"class":1057},"clientIp",[646,1536,1537],{"class":1064},"}:${",[646,1539,1540],{"class":1057},"normalizedAcct",[646,1542,1543],{"class":1064},"}`\n",[646,1545,1546,1548,1551,1553,1556,1558],{"class":648,"line":969},[646,1547,1473],{"class":1053},[646,1549,1550],{"class":1119}," acctKey",[646,1552,1157],{"class":1053},[646,1554,1555],{"class":1064}," `auth:acct:${",[646,1557,1540],{"class":1057},[646,1559,1543],{"class":1064},[646,1561,1562],{"class":648,"line":975},[646,1563,688],{"emptyLinePlaceholder":6},[646,1565,1566,1569,1572,1574,1577,1580],{"class":648,"line":980},[646,1567,1568],{"class":1053},"  for",[646,1570,1571],{"class":1057}," (",[646,1573,1151],{"class":1053},[646,1575,1576],{"class":1119}," key",[646,1578,1579],{"class":1053}," of",[646,1581,1582],{"class":1057}," [ipKey, acctKey]) {\n",[646,1584,1585,1588,1591,1593,1596,1599],{"class":648,"line":985},[646,1586,1587],{"class":1053},"    const",[646,1589,1590],{"class":1119}," rec",[646,1592,1157],{"class":1053},[646,1594,1595],{"class":1057}," attemptStore.",[646,1597,1598],{"class":1103},"get",[646,1600,1601],{"class":1057},"(key)\n",[646,1603,1604,1607,1610,1613,1616,1619],{"class":648,"line":990},[646,1605,1606],{"class":1053},"    if",[646,1608,1609],{"class":1057}," (rec ",[646,1611,1612],{"class":1053},"&&",[646,1614,1615],{"class":1057}," rec.lockedUntilMs ",[646,1617,1618],{"class":1053},">",[646,1620,1621],{"class":1057}," now) {\n",[646,1623,1624,1627,1630,1632,1635,1638,1641,1644,1647,1650,1652],{"class":648,"line":995},[646,1625,1626],{"class":1053},"      const",[646,1628,1629],{"class":1119}," retryAfterSec",[646,1631,1157],{"class":1053},[646,1633,1634],{"class":1057}," Math.",[646,1636,1637],{"class":1103},"ceil",[646,1639,1640],{"class":1057},"((rec.lockedUntilMs ",[646,1642,1643],{"class":1053},"-",[646,1645,1646],{"class":1057}," now) ",[646,1648,1649],{"class":1053},"/",[646,1651,1171],{"class":1119},[646,1653,1339],{"class":1057},[646,1655,1656,1659,1661,1664],{"class":648,"line":1000},[646,1657,1658],{"class":1103},"      setResponseHeader",[646,1660,1391],{"class":1057},[646,1662,1663],{"class":1064},"'Retry-After'",[646,1665,1666],{"class":1057},", retryAfterSec)\n",[646,1668,1669,1672,1675],{"class":648,"line":1005},[646,1670,1671],{"class":1053},"      throw",[646,1673,1674],{"class":1103}," createError",[646,1676,1677],{"class":1057},"({\n",[646,1679,1680,1683,1685],{"class":648,"line":1010},[646,1681,1682],{"class":1057},"        statusCode: ",[646,1684,781],{"class":1119},[646,1686,1687],{"class":1057},",\n",[646,1689,1690,1693,1696],{"class":648,"line":1015},[646,1691,1692],{"class":1057},"        statusMessage: ",[646,1694,1695],{"class":1064},"'Too Many Requests'",[646,1697,1687],{"class":1057},[646,1699,1701,1704,1707,1710,1713],{"class":648,"line":1700},45,[646,1702,1703],{"class":1057},"        message: ",[646,1705,1706],{"class":1064},"`Login attempts are temporarily throttled. Please retry in ${",[646,1708,1709],{"class":1057},"retryAfterSec",[646,1711,1712],{"class":1064},"} seconds.`",[646,1714,1687],{"class":1057},[646,1716,1718],{"class":648,"line":1717},46,[646,1719,1720],{"class":1057},"      })\n",[646,1722,1724],{"class":648,"line":1723},47,[646,1725,883],{"class":1057},[646,1727,1729],{"class":648,"line":1728},48,[646,1730,1731],{"class":1057},"  }\n",[646,1733,1735],{"class":648,"line":1734},49,[646,1736,688],{"emptyLinePlaceholder":6},[646,1738,1740,1742],{"class":648,"line":1739},50,[646,1741,1284],{"class":1053},[646,1743,1744],{"class":1057}," { ipKey, acctKey }\n",[646,1746,1748],{"class":648,"line":1747},51,[646,1749,816],{"class":1057},[646,1751,1753],{"class":648,"line":1752},52,[646,1754,688],{"emptyLinePlaceholder":6},[646,1756,1758,1760,1762,1765,1767,1770,1772,1774,1776,1778,1780,1782,1784,1786,1788,1791,1794,1796,1799,1801,1803,1806],{"class":648,"line":1757},53,[646,1759,1352],{"class":1053},[646,1761,1355],{"class":1053},[646,1763,1764],{"class":1103}," recordLoginResult",[646,1766,1263],{"class":1057},[646,1768,1769],{"class":1112},"keys",[646,1771,1116],{"class":1053},[646,1773,1448],{"class":1057},[646,1775,1451],{"class":1112},[646,1777,1116],{"class":1053},[646,1779,1271],{"class":1119},[646,1781,1458],{"class":1057},[646,1783,1461],{"class":1112},[646,1785,1116],{"class":1053},[646,1787,1271],{"class":1119},[646,1789,1790],{"class":1057}," }, ",[646,1792,1793],{"class":1112},"succeeded",[646,1795,1116],{"class":1053},[646,1797,1798],{"class":1119}," boolean",[646,1800,184],{"class":1057},[646,1802,1116],{"class":1053},[646,1804,1805],{"class":1119}," void",[646,1807,1107],{"class":1057},[646,1809,1811,1814],{"class":648,"line":1810},54,[646,1812,1813],{"class":1053},"  if",[646,1815,1816],{"class":1057}," (succeeded) {\n",[646,1818,1820,1823,1826],{"class":648,"line":1819},55,[646,1821,1822],{"class":1057},"    attemptStore.",[646,1824,1825],{"class":1103},"delete",[646,1827,1828],{"class":1057},"(keys.ipKey)\n",[646,1830,1832,1834,1836],{"class":648,"line":1831},56,[646,1833,1822],{"class":1057},[646,1835,1825],{"class":1103},[646,1837,1838],{"class":1057},"(keys.acctKey)\n",[646,1840,1842],{"class":648,"line":1841},57,[646,1843,1844],{"class":1053},"    return\n",[646,1846,1848],{"class":648,"line":1847},58,[646,1849,1731],{"class":1057},[646,1851,1853],{"class":648,"line":1852},59,[646,1854,688],{"emptyLinePlaceholder":6},[646,1856,1858,1860,1862,1864,1866,1868],{"class":648,"line":1857},60,[646,1859,1473],{"class":1053},[646,1861,1476],{"class":1119},[646,1863,1157],{"class":1053},[646,1865,1481],{"class":1057},[646,1867,1484],{"class":1103},[646,1869,1487],{"class":1057},[646,1871,1873,1875,1877,1879,1882,1885,1887,1890,1893,1896,1899,1902],{"class":648,"line":1872},61,[646,1874,1568],{"class":1053},[646,1876,1571],{"class":1057},[646,1878,1151],{"class":1053},[646,1880,1881],{"class":1057}," [",[646,1883,1884],{"class":1119},"idx",[646,1886,29],{"class":1057},[646,1888,1889],{"class":1119},"key",[646,1891,1892],{"class":1057},"] ",[646,1894,1895],{"class":1053},"of",[646,1897,1898],{"class":1057}," [keys.ipKey, keys.acctKey].",[646,1900,1901],{"class":1103},"entries",[646,1903,1904],{"class":1057},"()) {\n",[646,1906,1908,1910,1913,1915,1917,1919],{"class":648,"line":1907},62,[646,1909,1587],{"class":1053},[646,1911,1912],{"class":1119}," prev",[646,1914,1157],{"class":1053},[646,1916,1595],{"class":1057},[646,1918,1598],{"class":1103},[646,1920,1601],{"class":1057},[646,1922,1924,1926,1929,1931,1934,1936,1939,1941,1944,1946],{"class":648,"line":1923},63,[646,1925,1587],{"class":1053},[646,1927,1928],{"class":1119}," inWindow",[646,1930,1157],{"class":1053},[646,1932,1933],{"class":1057}," prev ",[646,1935,1612],{"class":1053},[646,1937,1938],{"class":1057}," (now ",[646,1940,1643],{"class":1053},[646,1942,1943],{"class":1057}," prev.windowStartMs) ",[646,1945,1237],{"class":1053},[646,1947,1948],{"class":1119}," WINDOW_MS\n",[646,1950,1952,1954,1957,1959,1962,1965,1968,1971,1974,1977],{"class":648,"line":1951},64,[646,1953,1587],{"class":1053},[646,1955,1956],{"class":1119}," failures",[646,1958,1157],{"class":1053},[646,1960,1961],{"class":1057}," inWindow ",[646,1963,1964],{"class":1053},"?",[646,1966,1967],{"class":1057}," prev.failures ",[646,1969,1970],{"class":1053},"+",[646,1972,1973],{"class":1119}," 1",[646,1975,1976],{"class":1053}," :",[646,1978,1979],{"class":1119}," 1\n",[646,1981,1983],{"class":648,"line":1982},65,[646,1984,1985],{"class":1047},"    // Global account key (idx === 1) uses a slightly wider threshold (THRESHOLD + 3) against distributed bots\n",[646,1987,1989,1991,1994,1996,1999,2002,2005,2008,2010,2012,2014,2017],{"class":648,"line":1988},66,[646,1990,1587],{"class":1053},[646,1992,1993],{"class":1119}," limit",[646,1995,1157],{"class":1053},[646,1997,1998],{"class":1057}," idx ",[646,2000,2001],{"class":1053},"===",[646,2003,2004],{"class":1119}," 0",[646,2006,2007],{"class":1053}," ?",[646,2009,1205],{"class":1119},[646,2011,1976],{"class":1053},[646,2013,1205],{"class":1119},[646,2015,2016],{"class":1053}," +",[646,2018,2019],{"class":1119}," 3\n",[646,2021,2023],{"class":648,"line":2022},67,[646,2024,688],{"emptyLinePlaceholder":6},[646,2026,2028,2031,2034,2037],{"class":648,"line":2027},68,[646,2029,2030],{"class":1053},"    let",[646,2032,2033],{"class":1057}," lockedUntilMs ",[646,2035,2036],{"class":1053},"=",[646,2038,2039],{"class":1119}," 0\n",[646,2041,2043,2045,2048,2051],{"class":648,"line":2042},69,[646,2044,1606],{"class":1053},[646,2046,2047],{"class":1057}," (failures ",[646,2049,2050],{"class":1053},">=",[646,2052,2053],{"class":1057}," limit) {\n",[646,2055,2057,2059,2062,2064,2066,2069,2071,2074,2076,2078,2081,2084,2086,2088,2091,2094],{"class":648,"line":2056},70,[646,2058,1626],{"class":1053},[646,2060,2061],{"class":1119}," expSec",[646,2063,1157],{"class":1053},[646,2065,1634],{"class":1057},[646,2067,2068],{"class":1103},"min",[646,2070,1263],{"class":1057},[646,2072,2073],{"class":1119},"BASE_LOCK_SEC",[646,2075,1163],{"class":1053},[646,2077,1571],{"class":1057},[646,2079,2080],{"class":1119},"2",[646,2082,2083],{"class":1053}," **",[646,2085,2047],{"class":1057},[646,2087,1643],{"class":1053},[646,2089,2090],{"class":1057}," limit)), ",[646,2092,2093],{"class":1119},"MAX_LOCK_SEC",[646,2095,1339],{"class":1057},[646,2097,2099,2102,2104,2107,2109,2112,2115],{"class":648,"line":2098},71,[646,2100,2101],{"class":1057},"      lockedUntilMs ",[646,2103,2036],{"class":1053},[646,2105,2106],{"class":1057}," now ",[646,2108,1970],{"class":1053},[646,2110,2111],{"class":1057}," expSec ",[646,2113,2114],{"class":1053},"*",[646,2116,2117],{"class":1119}," 1000\n",[646,2119,2121],{"class":648,"line":2120},72,[646,2122,883],{"class":1057},[646,2124,2126],{"class":648,"line":2125},73,[646,2127,688],{"emptyLinePlaceholder":6},[646,2129,2131,2133,2136],{"class":648,"line":2130},74,[646,2132,1822],{"class":1057},[646,2134,2135],{"class":1103},"set",[646,2137,2138],{"class":1057},"(key, {\n",[646,2140,2142],{"class":648,"line":2141},75,[646,2143,2144],{"class":1057},"      failures,\n",[646,2146,2148,2151,2153,2156,2158],{"class":648,"line":2147},76,[646,2149,2150],{"class":1057},"      windowStartMs: inWindow ",[646,2152,1964],{"class":1053},[646,2154,2155],{"class":1057}," prev.windowStartMs ",[646,2157,1116],{"class":1053},[646,2159,2160],{"class":1057}," now,\n",[646,2162,2164],{"class":648,"line":2163},77,[646,2165,2166],{"class":1057},"      lockedUntilMs,\n",[646,2168,2170],{"class":648,"line":2169},78,[646,2171,2172],{"class":1057},"    })\n",[646,2174,2176],{"class":648,"line":2175},79,[646,2177,1731],{"class":1057},[646,2179,2181],{"class":648,"line":2180},80,[646,2182,816],{"class":1057},[16,2184,2185,2186,2189,2190,2193],{},"Inside the login route handler (",[26,2187,2188],{},"/app/server/api/auth/login.post.ts","), ",[26,2191,2192],{},"assertLoginAllowed"," runs immediately after basic body validation, and missing accounts still execute an identical Argon2/scrypt verification against a dummy hash so response timings remain indistinguishable:",[186,2195,2197],{"className":1038,"code":2196,"language":1040,"meta":192,"style":192},"// /app/server/api/auth/login.post.ts\nimport { defineEventHandler, readBody, createError } from 'h3'\nimport { assertLoginAllowed, recordLoginResult } from '~/server/utils/authRateGuard'\n\nconst DUMMY_PASSWORD_HASH = '$scrypt$n=16384,r=8,p=1$c2FsdGVkX2R1bW15$8f9a2b3c4d5e6f7a8b9c0d1e2f3a4b5c'\n\nexport default defineEventHandler(async (event) => {\n  const body = await readBody\u003C{ email?: string; password?: string }>(event)\n  if (!body?.email || !body?.password) {\n    throw createError({ statusCode: 400, message: 'Email and password are required.' })\n  }\n\n  const guardKeys = assertLoginAllowed(event, body.email)\n  const user = await findUserByEmail(body.email)\n\n  // Constant-time password hash check prevents timing-based email registration enumeration\n  const targetHash = user?.passwordHash ?? DUMMY_PASSWORD_HASH\n  const isValid = await verifyPasswordSafe(body.password, targetHash)\n\n  if (!user || !isValid) {\n    recordLoginResult(guardKeys, false)\n    throw createError({ statusCode: 401, message: 'Invalid credentials.' })\n  }\n\n  recordLoginResult(guardKeys, true)\n  return issueUserSession(event, user.id)\n})\n",[26,2198,2199,2204,2215,2227,2231,2243,2247,2273,2310,2330,2352,2356,2360,2374,2391,2395,2400,2418,2435,2439,2457,2470,2488,2492,2496,2508,2518],{"__ignoreMap":192},[646,2200,2201],{"class":648,"line":649},[646,2202,2203],{"class":1047},"// /app/server/api/auth/login.post.ts\n",[646,2205,2206,2208,2211,2213],{"class":648,"line":655},[646,2207,1054],{"class":1053},[646,2209,2210],{"class":1057}," { defineEventHandler, readBody, createError } ",[646,2212,1061],{"class":1053},[646,2214,1080],{"class":1064},[646,2216,2217,2219,2222,2224],{"class":648,"line":661},[646,2218,1054],{"class":1053},[646,2220,2221],{"class":1057}," { assertLoginAllowed, recordLoginResult } ",[646,2223,1061],{"class":1053},[646,2225,2226],{"class":1064}," '~/server/utils/authRateGuard'\n",[646,2228,2229],{"class":648,"line":667},[646,2230,688],{"emptyLinePlaceholder":6},[646,2232,2233,2235,2238,2240],{"class":648,"line":673},[646,2234,1151],{"class":1053},[646,2236,2237],{"class":1119}," DUMMY_PASSWORD_HASH",[646,2239,1157],{"class":1053},[646,2241,2242],{"class":1064}," '$scrypt$n=16384,r=8,p=1$c2FsdGVkX2R1bW15$8f9a2b3c4d5e6f7a8b9c0d1e2f3a4b5c'\n",[646,2244,2245],{"class":648,"line":679},[646,2246,688],{"emptyLinePlaceholder":6},[646,2248,2249,2251,2254,2257,2259,2262,2264,2266,2268,2271],{"class":648,"line":685},[646,2250,1352],{"class":1053},[646,2252,2253],{"class":1053}," default",[646,2255,2256],{"class":1103}," defineEventHandler",[646,2258,1263],{"class":1057},[646,2260,2261],{"class":1053},"async",[646,2263,1571],{"class":1057},[646,2265,1363],{"class":1112},[646,2267,1397],{"class":1057},[646,2269,2270],{"class":1053},"=>",[646,2272,1107],{"class":1057},[646,2274,2275,2277,2280,2282,2285,2288,2291,2293,2296,2298,2300,2303,2305,2307],{"class":648,"line":691},[646,2276,1473],{"class":1053},[646,2278,2279],{"class":1119}," body",[646,2281,1157],{"class":1053},[646,2283,2284],{"class":1053}," await",[646,2286,2287],{"class":1103}," readBody",[646,2289,2290],{"class":1057},"\u003C{ ",[646,2292,562],{"class":1112},[646,2294,2295],{"class":1053},"?:",[646,2297,1271],{"class":1119},[646,2299,1458],{"class":1057},[646,2301,2302],{"class":1112},"password",[646,2304,2295],{"class":1053},[646,2306,1271],{"class":1119},[646,2308,2309],{"class":1057}," }>(event)\n",[646,2311,2312,2314,2316,2319,2322,2324,2327],{"class":648,"line":697},[646,2313,1813],{"class":1053},[646,2315,1571],{"class":1057},[646,2317,2318],{"class":1053},"!",[646,2320,2321],{"class":1057},"body?.email ",[646,2323,1400],{"class":1053},[646,2325,2326],{"class":1053}," !",[646,2328,2329],{"class":1057},"body?.password) {\n",[646,2331,2332,2335,2337,2340,2343,2346,2349],{"class":648,"line":703},[646,2333,2334],{"class":1053},"    throw",[646,2336,1674],{"class":1103},[646,2338,2339],{"class":1057},"({ statusCode: ",[646,2341,2342],{"class":1119},"400",[646,2344,2345],{"class":1057},", message: ",[646,2347,2348],{"class":1064},"'Email and password are required.'",[646,2350,2351],{"class":1057}," })\n",[646,2353,2354],{"class":648,"line":708},[646,2355,1731],{"class":1057},[646,2357,2358],{"class":648,"line":714},[646,2359,688],{"emptyLinePlaceholder":6},[646,2361,2362,2364,2367,2369,2371],{"class":648,"line":720},[646,2363,1473],{"class":1053},[646,2365,2366],{"class":1119}," guardKeys",[646,2368,1157],{"class":1053},[646,2370,1425],{"class":1103},[646,2372,2373],{"class":1057},"(event, body.email)\n",[646,2375,2376,2378,2381,2383,2385,2388],{"class":648,"line":726},[646,2377,1473],{"class":1053},[646,2379,2380],{"class":1119}," user",[646,2382,1157],{"class":1053},[646,2384,2284],{"class":1053},[646,2386,2387],{"class":1103}," findUserByEmail",[646,2389,2390],{"class":1057},"(body.email)\n",[646,2392,2393],{"class":648,"line":731},[646,2394,688],{"emptyLinePlaceholder":6},[646,2396,2397],{"class":648,"line":737},[646,2398,2399],{"class":1047},"  // Constant-time password hash check prevents timing-based email registration enumeration\n",[646,2401,2402,2404,2407,2409,2412,2415],{"class":648,"line":743},[646,2403,1473],{"class":1053},[646,2405,2406],{"class":1119}," targetHash",[646,2408,1157],{"class":1053},[646,2410,2411],{"class":1057}," user?.passwordHash ",[646,2413,2414],{"class":1053},"??",[646,2416,2417],{"class":1119}," DUMMY_PASSWORD_HASH\n",[646,2419,2420,2422,2425,2427,2429,2432],{"class":648,"line":749},[646,2421,1473],{"class":1053},[646,2423,2424],{"class":1119}," isValid",[646,2426,1157],{"class":1053},[646,2428,2284],{"class":1053},[646,2430,2431],{"class":1103}," verifyPasswordSafe",[646,2433,2434],{"class":1057},"(body.password, targetHash)\n",[646,2436,2437],{"class":648,"line":754},[646,2438,688],{"emptyLinePlaceholder":6},[646,2440,2441,2443,2445,2447,2450,2452,2454],{"class":648,"line":760},[646,2442,1813],{"class":1053},[646,2444,1571],{"class":1057},[646,2446,2318],{"class":1053},[646,2448,2449],{"class":1057},"user ",[646,2451,1400],{"class":1053},[646,2453,2326],{"class":1053},[646,2455,2456],{"class":1057},"isValid) {\n",[646,2458,2459,2462,2465,2468],{"class":648,"line":766},[646,2460,2461],{"class":1103},"    recordLoginResult",[646,2463,2464],{"class":1057},"(guardKeys, ",[646,2466,2467],{"class":1119},"false",[646,2469,1339],{"class":1057},[646,2471,2472,2474,2476,2478,2481,2483,2486],{"class":648,"line":772},[646,2473,2334],{"class":1053},[646,2475,1674],{"class":1103},[646,2477,2339],{"class":1057},[646,2479,2480],{"class":1119},"401",[646,2482,2345],{"class":1057},[646,2484,2485],{"class":1064},"'Invalid credentials.'",[646,2487,2351],{"class":1057},[646,2489,2490],{"class":648,"line":900},[646,2491,1731],{"class":1057},[646,2493,2494],{"class":648,"line":906},[646,2495,688],{"emptyLinePlaceholder":6},[646,2497,2498,2501,2503,2506],{"class":648,"line":911},[646,2499,2500],{"class":1103},"  recordLoginResult",[646,2502,2464],{"class":1057},[646,2504,2505],{"class":1119},"true",[646,2507,1339],{"class":1057},[646,2509,2510,2512,2515],{"class":648,"line":917},[646,2511,1284],{"class":1053},[646,2513,2514],{"class":1103}," issueUserSession",[646,2516,2517],{"class":1057},"(event, user.id)\n",[646,2519,2520],{"class":648,"line":923},[646,2521,2522],{"class":1057},"})\n",[320,2524,2525],{},[16,2526,2527,2529,2530,1571,2533,2536],{},[42,2528,326],{},"\nStoring raw email strings as in-memory or Redis rate-limit keys creates unnecessary PII exposure if operational dumps or cache keys ever leak. Lowercasing and hashing identifiers via one-way ",[26,2531,2532],{},"SHA-256",[26,2534,2535],{},"auth:acct:a1b2c3...",") lets you track distributed targeting accurately without persisting raw user emails in ephemeral security state.",[69,2538],{},[72,2540,2542],{"id":2541},"_5-deployment-verification-protocol-operational-checklist","5. Deployment Verification Protocol & Operational Checklist",[16,2544,2545,2546,29,2549,2552,2553,67],{},"Security architecture is never done at merge time. Before calling a rollout complete, verify three properties against live packet flows: ",[42,2547,2548],{},"① real-IP restoration accuracy",[42,2550,2551],{},"② spoofing resistance",", and ",[42,2554,2555],{},"③ collateral-free isolation (Self-DoS elimination)",[481,2557,2559,2560,2563],{"id":2558},"_51-cross-checking-realip_remote_addr-audit-logs","5.1. Cross-Checking ",[26,2561,2562],{},"$realip_remote_addr"," Audit Logs",[16,2565,2566,2567,2570,2571,2573,2574,2576,2577,2580],{},"With the ",[26,2568,2569],{},"security_audit"," log format enabled, every single access log line displays the restored client IP (",[26,2572,174],{},") side-by-side with the upstream TCP proxy edge socket (",[26,2575,2562],{},") and Cloudflare's ",[26,2578,2579],{},"CF-Ray"," trace ID:",[186,2582,2585],{"className":2583,"code":2584,"language":191,"meta":192},[189],"# [Origin Nginx audit log AFTER restoration — RFC 5737 documentation ranges]\n# Attacker (203.0.113.10) is isolated with 429 while legitimate user (192.0.2.25) on the exact same edge (198.51.100.14) receives 200 OK\n203.0.113.10 (edge:198.51.100.14) - [19/Nov/2026:14:22:08 +0900] \"POST /api/auth/login HTTP/2.0\" 429 94 \"python-requests/2.32\" cf_ray=\"8e4f1a2b3c-ICN\"\n192.0.2.25 (edge:198.51.100.14) - [19/Nov/2026:14:22:08 +0900] \"GET /jobs HTTP/2.0\" 200 18420 \"Mozilla/5.0\" cf_ray=\"8e4f1a2b41-ICN\"\n",[26,2586,2584],{"__ignoreMap":192},[16,2588,2589,2590,2593,2594,2596,2597,2599,2600,2602,2603,2605,2606,2608,2609,2612,2613,67],{},"Even though both requests arrived at the exact same second (",[26,2591,2592],{},"14:22:08",") through the exact same edge node (",[26,2595,125],{},"), only the threshold-breaking attacker IP (",[26,2598,84],{},") receives ",[26,2601,446],{}," with ",[26,2604,449],{},", while the legitimate visitor (",[26,2607,111],{},") loading ",[26,2610,2611],{},"/jobs"," gets a crisp, zero-delay ",[26,2614,2615],{},"200 OK",[320,2617,2618],{},[16,2619,2620,2622,2623,2626,2627,2629,2630,2632,2633,2636,2637,2640],{},[42,2621,326],{},"\nReverse-proxy defense is incomplete until ",[42,2624,2625],{},"Direct-to-Origin"," bypass paths are closed. No matter how tightly you configure Cloudflare WAF and ",[26,2628,303],{},", if origin ports ",[26,2631,345],{}," remain open to ",[26,2634,2635],{},"0.0.0.0/0",", attackers can pull historical DNS records and hit your origin directly. Lock your cloud firewall (Security Group / UFW) inbound rules exclusively to Cloudflare's official IP ranges—or pair them with ",[42,2638,2639],{},"Authenticated Origin Pulls (mTLS)","—to seal the perimeter end-to-end.",[481,2642,2644],{"id":2643},"_52-final-production-security-checklist-for-reverse-proxy-stacks","5.2. Final Production Security Checklist for Reverse-Proxy Stacks",[16,2646,2647],{},"Before deploying a Cloudflare + Nginx + Nuxt stack to production, run through these five mandatory checks:",[100,2649,2650,2669,2675,2692,2698],{},[103,2651,2652,2655,2656,2658,2659,2661,2662,2665,2666,2668],{},[42,2653,2654],{},"Trusted-CIDR Real-IP Restoration:"," Confirm ",[26,2657,508],{}," declares both verified ",[26,2660,303],{}," ranges and ",[26,2663,2664],{},"real_ip_header CF-Connecting-IP"," so ",[26,2667,58],{}," is never polluted by edge IPs.",[103,2670,2671,2674],{},[42,2672,2673],{},"Zero Direct-to-Origin Exposure:"," Verify via firewall rules or mTLS that direct TCP connections bypassing Cloudflare—and any spoofed header injection attempts—are dropped before reaching Nginx.",[103,2676,2677,2682,2683,2602,2686,2688,2689,2691],{},[42,2678,2679,2680,1116],{},"Route-Separated Buckets & Explicit ",[26,2681,446],{}," Isolate authentication endpoints from general browse/SSR zones, and enforce ",[26,2684,2685],{},"limit_req_status 429",[26,2687,449],{}," headers to eliminate ",[26,2690,551],{}," false-outage alarms.",[103,2693,2694,2697],{},[42,2695,2696],{},"Composite Account + IP Application Guard:"," Validate that your Nitro server runtime enforces hashed per-account sliding windows, exponential backoff, and constant-time dummy password verification against rotating proxy botnets.",[103,2699,2700,2703,2704,29,2706,2552,2708,2711],{},[42,2701,2702],{},"End-to-End Audit Log Visibility:"," Ensure access logs record ",[26,2705,174],{},[26,2707,2562],{},[26,2709,2710],{},"$http_cf_ray"," together so incident triage can immediately separate edge behavior from client traffic.",[16,2713,2714,2715,67],{},"You can explore the platform architecture and technical specs on the ",[20,2716,2718],{"href":2717},"/en/projects/photojob","PhotoJob project page",[69,2720],{},[72,2722,2724],{"id":2723},"frequently-asked-questions","Frequently Asked Questions",[481,2726,2728],{"id":2727},"what-is-the-difference-between-cf-connecting-ip-and-x-forwarded-for","What is the difference between CF-Connecting-IP and X-Forwarded-For?",[16,2730,2731,2733,2734,2736,2737,2739],{},[26,2732,218],{}," appends every proxy hop into a comma-separated chain, making it easy for clients to prepend spoofed IP addresses. ",[26,2735,47],{}," is a dedicated single-IP header overwritten by the Cloudflare edge with the true connecting client IP, so trusting it strictly from verified Cloudflare CIDR blocks (",[26,2738,303],{},") provides cleaner and safer real-IP restoration.",[481,2741,2743],{"id":2742},"why-does-omitting-set_real_ip_from-in-nginx-cause-a-self-dos-outage","Why does omitting set_real_ip_from in Nginx cause a Self-DoS outage?",[16,2745,2746,2747,329,2749,2751,2752,329,2754,2756,2757,2759],{},"Without ",[26,2748,303],{},[26,2750,2664],{},", Nginx records the Cloudflare edge node IP that opened the upstream TCP socket as ",[26,2753,174],{},[26,2755,58],{},". When ",[26,2758,39],{}," is enabled in that state, thousands of legitimate visitors and attacking bots sharing the same regional edge PoP share a single rate-limit bucket, causing immediate collateral lockouts (Self-DoS).",[481,2761,2763],{"id":2762},"how-do-i-verify-that-cf-connecting-ip-real-ip-restoration-works-in-a-docker-nginx-setup","How do I verify that CF-Connecting-IP real IP restoration works in a Docker + Nginx setup?",[16,2765,2766,2767,2769,2770,2772,2773,2775,2776,2778,2779,2781,2782,2784,2785,67],{},"Log the restored client IP (",[26,2768,174],{},"), the raw upstream proxy socket IP (",[26,2771,2562],{},"), and the trace ID (",[26,2774,2710],{},") side by side in your Nginx access log. When restoration works properly, ",[26,2777,174],{}," shows the real public client IP while ",[26,2780,2562],{}," shows the Cloudflare edge IP (or internal proxy bridge IP), and triggering ",[26,2783,446],{}," from one test IP leaves normal browsing from another IP unaffected with ",[26,2786,2615],{},[481,2788,2790],{"id":2789},"how-should-set_real_ip_from-be-maintained-when-cloudflare-updates-its-ip-ranges","How should set_real_ip_from be maintained when Cloudflare updates its IP ranges?",[16,2792,2793,2794,2797,2798,2801,2802,2804,2805,2808,2809,2811,2812,2814,2815,2818],{},"Automate syncing Cloudflare's official published IPv4 (",[26,2795,2796],{},"/ips-v4",") and IPv6 (",[26,2799,2800],{},"/ips-v6",") lists into a dedicated Nginx include file such as ",[26,2803,625],{}," via a ",[26,2806,2807],{},"cron"," job or ",[26,2810,632],{}," timer. Always gate reloads on a passing ",[26,2813,636],{}," validation check before running ",[26,2816,2817],{},"nginx -s reload"," so an upstream fetch failure never breaks live traffic.",[2820,2821,2822],"style",{},"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 .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 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}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}",{"title":192,"searchDepth":655,"depth":655,"links":2824},[2825,2826,2828,2834,2838,2843],{"id":74,"depth":655,"text":75},{"id":161,"depth":655,"text":2827},"2. Why Legitimate Users Get Blocked: $binary_remote_addr Pollution and the Header-Spoofing Dilemma",{"id":351,"depth":655,"text":352,"children":2829},[2830,2831,2833],{"id":483,"depth":661,"text":484},{"id":504,"depth":661,"text":2832},"3.2. Layer 2 — Nginx ngx_http_realip_module Restoration & Differentiated HTTP 429 Zones",{"id":555,"depth":661,"text":556},{"id":597,"depth":655,"text":598,"children":2835},[2836,2837],{"id":618,"depth":661,"text":619},{"id":1020,"depth":661,"text":1021},{"id":2541,"depth":655,"text":2542,"children":2839},[2840,2842],{"id":2558,"depth":661,"text":2841},"5.1. Cross-Checking $realip_remote_addr Audit Logs",{"id":2643,"depth":661,"text":2644},{"id":2723,"depth":655,"text":2724,"children":2844},[2845,2846,2847,2848],{"id":2727,"depth":661,"text":2728},{"id":2742,"depth":661,"text":2743},{"id":2762,"depth":661,"text":2763},{"id":2789,"depth":661,"text":2790},"CF-Connecting-IP Restoration · 3-Layer Botnet Defense","tech","/images/content-images/blog/20261119-Cloudflare-CF-Connecting-IP-Multi-Layer-Botnet-Defense/20261119-Cloudflare-CF-Connecting-IP-Multi-Layer-Botnet-Defense001.jpg","Matte-black editorial cover contrasting Cloudflare reverse-proxy edge-IP Self-DoS when CF-Connecting-IP is missing against a 3-layer WAF, Nginx HTTP 429, and Nuxt 4 defense architecture","2026-11-19","Fix Cloudflare edge-IP Self-DoS with Nginx set_real_ip_from and CF-Connecting-IP, then build a 3-layer WAF, Nginx HTTP 429, and Nuxt 4 botnet defense.","md",[2857,2859,2861,2863],{"question":2728,"answer":2858},"X-Forwarded-For appends every proxy hop into a comma-separated chain, making it easy for clients to prepend spoofed IP addresses. CF-Connecting-IP is a dedicated single-IP header overwritten by the Cloudflare edge with the true connecting client IP, so trusting it strictly from verified Cloudflare CIDR blocks (set_real_ip_from) provides cleaner and safer real-IP restoration.",{"question":2743,"answer":2860},"Without set_real_ip_from and real_ip_header CF-Connecting-IP, Nginx records the Cloudflare edge node IP that opened the upstream TCP socket as $remote_addr and $binary_remote_addr. When limit_req is enabled in that state, thousands of legitimate visitors and attacking bots sharing the same regional edge PoP share a single rate-limit bucket, causing immediate collateral lockouts (Self-DoS).",{"question":2763,"answer":2862},"Log the restored client IP ($remote_addr), the raw upstream proxy socket IP ($realip_remote_addr), and the trace ID ($http_cf_ray) side by side in your Nginx access log. When restoration works properly, $remote_addr shows the real public client IP while $realip_remote_addr shows the Cloudflare edge IP (or internal proxy bridge IP), and triggering HTTP 429 from one test IP leaves normal browsing from another IP unaffected with 200 OK.",{"question":2790,"answer":2864},"Automate syncing Cloudflare's official published IPv4 (/ips-v4) and IPv6 (/ips-v6) lists into a dedicated Nginx include file such as /etc/nginx/conf.d/cloudflare-realip.conf via a cron job or systemd timer. Always gate reloads on a passing nginx -t validation check before running nginx -s reload so an upstream fetch failure never breaks live traffic.",{},false,"/en/blog/20261119-cloudflare-cf-connecting-ip-multi-layer-botnet-defense","photojob",{"title":5,"description":2854},"Configure Nginx set_real_ip_from and real_ip_header CF-Connecting-IP to restore real client IPs, stop Cloudflare edge-IP Self-DoS, and deploy 3-layer WAF, Nginx 429, and Nuxt 4 botnet defense.","Cloudflare CF-Connecting-IP in Nginx — Fix Real IP & Edge 429 Self-DoS | inmokang.com","published","en/blog/20261119-Cloudflare-CF-Connecting-IP-Multi-Layer-Botnet-Defense",[2875,2876,2877,2878,2879],"Cloudflare","Nginx","Security Architecture","Rate Limiting","Nuxt 4","jKStTALTuPBQEwWS8cRGzMtnvKIcmoO778juIAChJYk",{"path":2717,"title":2882,"subtitle":2883,"track":2884,"liveUrl":22,"liveLabel":2885,"date":2886,"status":2872},"PhotoJob — Commercial Photography Hiring & Studio Matching Platform","A commercial photography ecosystem linking short-form Photoshop/Lightroom education with structured crew hiring, equipment compatibility, and rental studio specs","web-product","Visit PhotoJob Live","2025-11-20","/blog/20261119-cloudflare-cf-connecting-ip-multi-layer-botnet-defense",[2889,2894],{"title":2890,"path":2891,"stem":2892,"date":2893,"status":2872,"noindex":2866,"children":-1},"Breaking the New-Domain Search Bottleneck: 5-Locale Nuxt Programmatic SEO & 295-URL Architecture","/en/blog/20261117-nuxt-multilingual-programmatic-seo-architecture","en/blog/20261117-Nuxt-Multilingual-Programmatic-SEO-Architecture","2026-11-17",{"title":2895,"path":2896,"stem":2897,"date":2853,"status":2872,"noindex":2866,"children":-1},"Designing Hardware with Python Instead of a Mouse: build123d Parametric CAD & Klipper High-Speed 3D Printing","/en/blog/20261119-parametric-python-cad-build123d-klipper-workflow","en/blog/20261119-Parametric-Python-CAD-Build123d-Klipper-Workflow",1796290674304]