{"id":87805,"date":"2026-07-30T22:56:33","date_gmt":"2026-07-30T14:56:33","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/87805.html"},"modified":"2026-07-30T22:56:33","modified_gmt":"2026-07-30T14:56:33","slug":"nginx%e5%a4%96%e7%bd%ae%e7%bc%93%e5%ad%98-error_page","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/87805.html","title":{"rendered":"Nginx\u5916\u7f6e\u7f13\u5b58-error_page"},"content":{"rendered":"<h3>\u4e00\u3001\u5f15\u8a00&#xff1a;\u5f53\u7f13\u5b58\u6210\u4e3a\u6545\u969c\u6e90&#xff0c;error_page\u662f\u6700\u540e\u9632\u7ebf<\/h3>\n<p>\u5728\u300aNginx\u5916\u7f6e\u7f13\u5b58\u300b\u7cfb\u5217\u524d\u6587\u4e2d&#xff0c;\u6211\u4eec\u6784\u5efa\u4e86\u4ee5OpenResty &#043; Redis\u4e3a\u6838\u5fc3\u7684\u5206\u5e03\u5f0f\u7f13\u5b58\u4f53\u7cfb\u3002\u8fd9\u5957\u67b6\u6784\u5728\u6b63\u5e38\u60c5\u51b5\u4e0b\u8868\u73b0\u4f18\u5f02&#xff0c;\u4f46\u751f\u4ea7\u73af\u5883\u7684\u6b8b\u9177\u73b0\u5b9e\u662f&#xff1a;\u5916\u7f6e\u7f13\u5b58\u672c\u8eab\u53ef\u80fd\u6210\u4e3a\u6700\u5927\u7684\u5355\u70b9\u6545\u969c\u3002<\/p>\n<ul>\n<li>Redis\u96c6\u7fa4\u4e3b\u4ece\u5207\u6362\u671f\u95f4&#xff0c;\u6570\u767e\u6beb\u79d2\u7684\u5199\u5165\u963b\u585e\u5bfc\u81f4Nginx\u5927\u91cf504&#xff1b;<\/li>\n<li>\u7f13\u5b58\u670d\u52a1OOM\u91cd\u542f&#xff0c;\u6240\u6709\u8bf7\u6c42\u77ac\u95f4\u7a7f\u900f\u5230\u6e90\u7ad9&#xff0c;\u5f15\u53d1\u96ea\u5d29&#xff1b;<\/li>\n<li>Lua\u811a\u672cbug\u5bfc\u81f4Redis\u8fde\u63a5\u6c60\u8017\u5c3d&#xff0c;\u6b63\u5e38\u4e1a\u52a1\u88ab\u7f13\u5b58\u6a21\u5757\u62d6\u57ae&#xff1b;<\/li>\n<li>\u7f51\u7edc\u5206\u533a\u4f7fRedis\u4e0d\u53ef\u8fbe&#xff0c;error_log\u4e2d\u5237\u5c4fconnection refused&#xff0c;\u7528\u6237\u770b\u5230\u9ed8\u8ba4500\u767d\u9875&#xff1b;<\/li>\n<li>\u7f13\u5b58\u8fd4\u56de\u4e86\u635f\u574f\u7684\u6570\u636e&#xff08;\u5982\u622a\u65ad\u7684JSON&#xff09;&#xff0c;\u5ba2\u6237\u7aef\u89e3\u6790\u5931\u8d25\u5374\u65e0\u4ece\u6062\u590d\u3002<\/li>\n<\/ul>\n<p>\u8fd9\u4e9b\u573a\u666f\u7684\u5171\u540c\u70b9\u662f&#xff1a;\u7f13\u5b58\u5c42\u7684\u5f02\u5e38\u6ca1\u6709\u88ab\u4f18\u96c5\u5730\u6355\u83b7\u548c\u8f6c\u5316\u3002\u9ed8\u8ba4\u7684Nginx\u9519\u8bef\u5904\u7406\u673a\u5236\u5bf9Lua\u5c42\u9762\u7684\u5f02\u5e38\u51e0\u4e4e\u65e0\u611f\u77e5&#xff0c;\u800c\u5f00\u53d1\u8005\u5f80\u5f80\u53ea\u5173\u6ce8\u201c\u7f13\u5b58\u547d\u4e2d\u65f6\u7684\u6027\u80fd\u201d&#xff0c;\u5ffd\u7565\u4e86\u201c\u7f13\u5b58\u5931\u6548\u65f6\u7684\u751f\u5b58\u80fd\u529b\u201d\u3002<\/p>\n<p>error_page\u00a0\u6307\u4ee4\u5728\u4f20\u7edfNginx\u4e2d\u7528\u4e8e\u81ea\u5b9a\u4e49\u9519\u8bef\u9875\u9762&#xff0c;\u4f46\u5728\u5916\u7f6e\u7f13\u5b58\u67b6\u6784\u4e2d&#xff0c;\u5b83\u7684\u89d2\u8272\u8fdc\u4e0d\u6b62\u4e8e\u6b64\u2014\u2014\u5b83\u662f\u7f13\u5b58\u6545\u969c\u4e0e\u670d\u52a1\u53ef\u7528\u6027\u4e4b\u95f4\u7684\u9694\u79bb\u9600&#xff0c;\u662f\u964d\u7ea7\u7b56\u7565\u7684\u6267\u884c\u5165\u53e3&#xff0c;\u662f\u7528\u6237\u4f53\u9a8c\u7684\u6700\u540e\u4e00\u9053\u4fdd\u969c\u3002\u672c\u6587\u5c06\u91cd\u65b0\u5b9a\u4e49\u00a0error_page\u00a0\u5728\u5916\u7f6e\u7f13\u5b58\u573a\u666f\u4e0b\u7684\u7528\u6cd5&#xff0c;\u4ece\u57fa\u7840\u8bed\u6cd5\u5230\u9ad8\u7ea7\u964d\u7ea7\u6a21\u5f0f&#xff0c;\u7ed9\u51fa\u751f\u4ea7\u7ea7\u5bb9\u9519\u67b6\u6784\u3002<\/p>\n<hr \/>\n<h3>\u4e8c\u3001error_page\u5728\u5916\u7f6e\u7f13\u5b58\u4e2d\u7684\u4e09\u91cd\u89d2\u8272<\/h3>\n<h4>2.1 \u89d2\u8272\u91cd\u5b9a\u4e49<\/h4>\n<table>\n<tr>\u4f20\u7edf\u89d2\u8272\u5916\u7f6e\u7f13\u5b58\u4e2d\u7684\u65b0\u89d2\u8272\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u81ea\u5b9a\u4e49\u9519\u8bef\u9875\u9762<\/td>\n<td>\u964d\u7ea7\u89e6\u53d1\u5668<\/td>\n<td>\u5c06\u7f13\u5b58\u9519\u8bef\u8f6c\u5316\u4e3a\u53ef\u5904\u7406\u7684\u5185\u90e8\u8df3\u8f6c<\/td>\n<\/tr>\n<tr>\n<td>\u9759\u6001\u5185\u5bb9\u5c55\u793a<\/td>\n<td>\u52a8\u6001\u964d\u7ea7\u8def\u7531<\/td>\n<td>\u6839\u636e\u9519\u8bef\u7c7b\u578b\u9009\u62e9\u4e0d\u540c\u7684\u56de\u9000\u8def\u5f84<\/td>\n<\/tr>\n<tr>\n<td>\u7528\u6237\u53cb\u597d\u63d0\u793a<\/td>\n<td>\u53ef\u89c2\u6d4b\u6027\u63a2\u9488<\/td>\n<td>\u901a\u8fc7\u4e0d\u540c\u72b6\u6001\u7801\u533a\u5206\u7f13\u5b58\u6545\u969c\u7c7b\u578b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#x1f4cc;\u00a0\u6838\u5fc3\u8ba4\u77e5&#xff1a;\u5728\u5916\u7f6e\u7f13\u5b58\u67b6\u6784\u4e2d&#xff0c;error_page\u00a0\u4e0d\u518d\u662f\u201c\u7ed9\u7528\u6237\u770b\u7684\u9875\u9762\u201d&#xff0c;\u800c\u662f\u201c\u7ed9\u7cfb\u7edf\u7528\u7684\u63a7\u5236\u6d41\u201d\u3002\u5b83\u62e6\u622a\u7684\u662f\u57fa\u7840\u8bbe\u65bd\u5c42\u7684\u5f02\u5e38&#xff0c;\u8f93\u51fa\u7684\u662f\u67b6\u6784\u5c42\u7684\u51b3\u7b56\u3002<\/p>\n<h4>2.2 \u4e3a\u4ec0\u4e48\u4e0d\u80fd\u53ea\u5728Lua\u91cctry-catch&#xff1f;<\/h4>\n<p>\u5f88\u591a\u5f00\u53d1\u8005\u8ba4\u4e3a\u5728Lua\u4ee3\u7801\u4e2d\u7528\u00a0pcall\u00a0\u5305\u88f9Redis\u64cd\u4f5c\u5c31\u591f\u4e86\u3002\u4f46\u8fd9\u6709\u4e09\u4e2a\u76f2\u533a&#xff1a;<\/p>\n<li>Nginx\u539f\u751f\u9519\u8bef\u65e0\u6cd5\u6355\u83b7&#xff1a;proxy_pass\u00a0\u8d85\u65f6\u3001upstream\u8fde\u63a5\u5931\u8d25\u7b49\u53d1\u751f\u5728C\u5c42\u9762&#xff0c;Lua\u7684\u00a0pcall\u00a0\u770b\u4e0d\u5230&#xff1b;<\/li>\n<li>\u5b50\u8bf7\u6c42\u9519\u8bef\u4e0d\u4f20\u64ad&#xff1a;ngx.location.capture\u00a0\u8fd4\u56de\u7684\u9519\u8bef\u72b6\u6001\u7801\u4e0d\u4f1a\u81ea\u52a8\u89e6\u53d1\u5916\u5c42Lua\u7684\u5f02\u5e38\u5904\u7406&#xff1b;<\/li>\n<li>\u7edf\u4e00\u964d\u7ea7\u7b56\u7565\u96be\u7ef4\u62a4&#xff1a;\u6bcf\u4e2alocation\u90fd\u5199\u4e00\u5957try-catch&#043;\u964d\u7ea7\u903b\u8f91&#xff0c;\u4ee3\u7801\u81a8\u80c0\u4e14\u4e0d\u4e00\u81f4\u3002<\/li>\n<p>error_page\u00a0\u63d0\u4f9b\u4e86\u58f0\u660e\u5f0f\u7684\u3001\u8de8\u5c42\u7ea7\u7684\u9519\u8bef\u5904\u7406\u673a\u5236&#xff0c;\u4e0eLua\u7684\u547d\u4ee4\u5f0f\u5f02\u5e38\u5904\u7406\u4e92\u8865&#xff0c;\u800c\u975e\u66ff\u4ee3\u3002<\/p>\n<hr \/>\n<h3>\u4e09\u3001\u57fa\u7840\u914d\u7f6e&#xff1a;\u7f13\u5b58\u9519\u8bef\u7684\u7cbe\u51c6\u6355\u83b7<\/h3>\n<h4>3.1 \u533a\u5206\u7f13\u5b58\u76f8\u5173\u9519\u8bef\u7801<\/h4>\n<p>server {<br \/>\n    listen 80;<\/p>\n<p>    # &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u7f13\u5b58\u4e13\u7528\u9519\u8bef\u6620\u5c04 &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<br \/>\n    # Redis\u8fde\u63a5\u5931\u8d25\/\u8d85\u65f6 \u2192 590 (\u81ea\u5b9a\u4e49)<br \/>\n    error_page 590 &#061; &#064;cache_fallback_backend;<\/p>\n<p>    # \u7f13\u5b58\u6570\u636e\u635f\u574f\/\u89e3\u6790\u5931\u8d25 \u2192 591<br \/>\n    error_page 591 &#061; &#064;cache_fallback_stale;<\/p>\n<p>    # \u6e90\u7ad9\u4e5f\u5931\u8d25 \u2192 592<br \/>\n    error_page 592 &#061; &#064;cache_static_degraded;<\/p>\n<p>    # \u6807\u51c6\u9519\u8bef\u515c\u5e95<br \/>\n    error_page 500 502 503 504 \/50x.html;<\/p>\n<p>    location \/api\/ {<br \/>\n        content_by_lua_block {<br \/>\n            &#8212; Lua\u7f13\u5b58\u903b\u8f91&#xff08;\u89c1\u4e0b\u6587&#xff09;<br \/>\n        }<br \/>\n    }<\/p>\n<p>    # &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u964d\u7ea7\u5904\u7406\u5668 &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<br \/>\n    location &#064;cache_fallback_backend {<br \/>\n        internal;<br \/>\n        add_header X-Cache-Degraded &#034;redis-unavailable&#034; always;<br \/>\n        proxy_pass http:\/\/backend;<br \/>\n        proxy_connect_timeout 3s;      # \u2b50 \u964d\u7ea7\u65f6\u7f29\u77ed\u8d85\u65f6<br \/>\n        proxy_read_timeout 5s;<br \/>\n    }<\/p>\n<p>    location &#064;cache_fallback_stale {<br \/>\n        internal;<br \/>\n        add_header X-Cache-Degraded &#034;stale-data&#034; always;<br \/>\n        # \u5c1d\u8bd5\u8bfb\u53d6\u672c\u5730\u5907\u4efd\u6216\u8fd4\u56de\u9884\u8bbe\u9ed8\u8ba4\u503c<br \/>\n        content_by_lua_block {<br \/>\n            local fallback &#061; ngx.shared.local_cache:get(&#034;fallback:&#034; .. ngx.var.uri)<br \/>\n            if fallback then<br \/>\n                ngx.header[&#034;X-Cache&#034;] &#061; &#034;STALE-HIT&#034;<br \/>\n                ngx.say(fallback)<br \/>\n            else<br \/>\n                ngx.status &#061; 503<br \/>\n                ngx.say(&#039;{&#034;error&#034;:&#034;service temporarily unavailable&#034;}&#039;)<br \/>\n            end<br \/>\n        }<br \/>\n    }<\/p>\n<p>    location &#064;cache_static_degraded {<br \/>\n        internal;<br \/>\n        add_header X-Cache-Degraded &#034;full-degradation&#034; always;<br \/>\n        default_type application\/json;<br \/>\n        return 503 &#039;{&#034;code&#034;:503,&#034;msg&#034;:&#034;service degraded&#034;,&#034;retry_after&#034;:30}&#039;;<br \/>\n    }<br \/>\n}<\/p>\n<h4>3.2 \u81ea\u5b9a\u4e49\u9519\u8bef\u7801\u7684\u610f\u4e49<\/h4>\n<p>Nginx\u6807\u51c6\u9519\u8bef\u7801\u65e0\u6cd5\u533a\u5206\u201cRedis\u6302\u4e86\u201d\u548c\u201c\u6e90\u7ad9\u6302\u4e86\u201d\u3002\u81ea\u5b9a\u4e49590\/591\/592\u8ba9\u76d1\u63a7\u548c\u964d\u7ea7\u7b56\u7565\u53ef\u4ee5\u7cbe\u786e\u8bc6\u522b\u6545\u969c\u5c42\u7ea7&#xff1a;<\/p>\n<table>\n<tr>\u81ea\u5b9a\u4e49\u7801\u542b\u4e49\u964d\u7ea7\u52a8\u4f5c\u544a\u8b66\u7ea7\u522b<\/tr>\n<tbody>\n<tr>\n<td>590<\/td>\n<td>Redis\u4e0d\u53ef\u7528<\/td>\n<td>\u8df3\u8fc7\u7f13\u5b58&#xff0c;\u76f4\u8fde\u6e90\u7ad9<\/td>\n<td>P2<\/td>\n<\/tr>\n<tr>\n<td>591<\/td>\n<td>\u7f13\u5b58\u6570\u636e\u5f02\u5e38<\/td>\n<td>\u8fd4\u56de\u8fc7\u671f\u6570\u636e\u6216\u9ed8\u8ba4\u503c<\/td>\n<td>P3<\/td>\n<\/tr>\n<tr>\n<td>592<\/td>\n<td>\u6e90\u7ad9&#043;\u7f13\u5b58\u5747\u5931\u8d25<\/td>\n<td>\u8fd4\u56de\u9759\u6001\u515c\u5e95\u54cd\u5e94<\/td>\n<td>P1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u26a0\ufe0f\u00a0\u6ce8\u610f&#xff1a;\u81ea\u5b9a\u4e49\u9519\u8bef\u7801\u4ec5\u5728Nginx\u5185\u90e8\u6d41\u8f6c&#xff0c;\u4e0d\u4f1a\u66b4\u9732\u7ed9\u5ba2\u6237\u7aef\u3002\u6700\u7ec8\u5bf9\u5916\u8fd4\u56de\u7684\u4ecd\u662f\u6807\u51c6HTTP\u72b6\u6001\u7801&#xff08;200\/503\u7b49&#xff09;\u3002<\/p>\n<hr \/>\n<h3>\u56db\u3001Lua\u5c42\u4e0eerror_page\u7684\u6865\u63a5<\/h3>\n<h4>4.1 \u5728Lua\u4e2d\u89e6\u53d1error_page<\/h4>\n<p>Lua\u4ee3\u7801\u4e0d\u80fd\u76f4\u63a5\u201c\u8c03\u7528\u201derror_page&#xff0c;\u4f46\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u7279\u5b9a\u72b6\u6001\u7801\u6765\u95f4\u63a5\u89e6\u53d1&#xff1a;<\/p>\n<p>&#8212; cache_handler.lua \u589e\u5f3a\u7248<br \/>\nlocal redis &#061; require &#034;resty.redis&#034;<\/p>\n<p>local _M &#061; {}<\/p>\n<p>function _M.get(key)<br \/>\n    local red, err &#061; get_redis()<br \/>\n    if not red then<br \/>\n        &#8212; \u2b50 \u8bbe\u7f6e\u81ea\u5b9a\u4e49\u72b6\u6001\u7801&#xff0c;\u89e6\u53d1error_page 590<br \/>\n        ngx.status &#061; 590<br \/>\n        ngx.log(ngx.WARN, &#034;redis connect failed, triggering fallback: &#034;, err)<br \/>\n        return nil, &#034;REDIS_UNAVAILABLE&#034;<br \/>\n    end<\/p>\n<p>    local res, err &#061; red:get(key)<br \/>\n    release_redis(red)<\/p>\n<p>    if not res or res &#061;&#061; ngx.null then<br \/>\n        return nil, &#034;MISS&#034;<br \/>\n    end<\/p>\n<p>    &#8212; \u9a8c\u8bc1\u6570\u636e\u5b8c\u6574\u6027<br \/>\n    local data, decode_err &#061; cjson.decode(res)<br \/>\n    if not data then<br \/>\n        &#8212; \u2b50 \u6570\u636e\u635f\u574f&#xff0c;\u89e6\u53d1error_page 591<br \/>\n        ngx.status &#061; 591<br \/>\n        ngx.log(ngx.ERR, &#034;cache data corrupted for key: &#034;, key, &#034; err: &#034;, decode_err)<br \/>\n        return nil, &#034;DATA_CORRUPTED&#034;<br \/>\n    end<\/p>\n<p>    return data, nil<br \/>\nend<\/p>\n<p>return _M<\/p>\n<h4>4.2 content_by_lua_block\u4e2d\u7684\u9519\u8bef\u5904\u7406\u8303\u5f0f<\/h4>\n<p>content_by_lua_block {<br \/>\n    local key &#061; build_cache_key()<\/p>\n<p>    &#8212; \u5c1d\u8bd5\u7f13\u5b58<br \/>\n    local data, err &#061; cache_handler.get(key)<\/p>\n<p>    if err &#061;&#061; &#034;REDIS_UNAVAILABLE&#034; or err &#061;&#061; &#034;DATA_CORRUPTED&#034; then<br \/>\n        &#8212; \u2b50 \u5173\u952e&#xff1a;exit\u8ba9Nginx\u63a5\u7ba1error_page\u5904\u7406<br \/>\n        &#8212; \u6b64\u65f6ngx.status\u5df2\u88ab\u8bbe\u4e3a590\/591<br \/>\n        return ngx.exit(ngx.status)<br \/>\n    end<\/p>\n<p>    if data then<br \/>\n        ngx.header[&#034;X-Cache&#034;] &#061; &#034;HIT&#034;<br \/>\n        ngx.say(cjson.encode(data))<br \/>\n        return<br \/>\n    end<\/p>\n<p>    &#8212; MISS&#xff1a;\u56de\u6e90\u5e76\u56de\u586b\u7f13\u5b58<br \/>\n    local res &#061; ngx.location.capture(&#034;\/internal\/backend&#034;)<br \/>\n    if res.status ~&#061; 200 then<br \/>\n        &#8212; \u6e90\u7ad9\u5931\u8d25&#xff0c;\u4f46\u7f13\u5b58\u4e5f\u4e0d\u53ef\u7528 \u2192 \u89e6\u53d1592<br \/>\n        ngx.status &#061; 592<br \/>\n        return ngx.exit(592)<br \/>\n    end<\/p>\n<p>    &#8212; \u6b63\u5e38\u56de\u586b&#8230;<br \/>\n    cache_handler.set(key, cjson.decode(res.body), 300)<br \/>\n    ngx.say(res.body)<br \/>\n}<\/p>\n<h4>4.3 \u4e09\u4e2a\u5173\u952e\u9677\u9631<\/h4>\n<h5>\u2460 ngx.exit\u5fc5\u987b\u5728header\u53d1\u9001\u524d\u8c03\u7528<\/h5>\n<p>\u4e00\u65e6\u8c03\u7528\u4e86\u00a0ngx.say()\u00a0\u6216\u00a0ngx.print()&#xff0c;\u54cd\u5e94\u5934\u5df2\u53d1\u9001&#xff0c;ngx.exit\u00a0\u65e0\u6cd5\u6539\u53d8\u72b6\u6001\u7801&#xff0c;error_page\u4e5f\u4e0d\u4f1a\u89e6\u53d1\u3002\u6240\u6709\u9519\u8bef\u5224\u65ad\u5fc5\u987b\u5728\u9996\u6b21\u8f93\u51fa\u4e4b\u524d\u5b8c\u6210\u3002<\/p>\n<h5>\u2461 error_page\u7684&#061;\u53f7\u8bed\u6cd5\u51b3\u5b9a\u72b6\u6001\u7801\u4f20\u9012<\/h5>\n<p># \u274c \u4fdd\u7559\u539f\u59cb\u9519\u8bef\u7801590&#xff0c;\u5ba2\u6237\u7aef\u770b\u5230\u975e\u6807\u51c6\u72b6\u6001\u7801<br \/>\nerror_page 590 &#064;cache_fallback_backend;<\/p>\n<p># \u2705 \u4f7f\u7528&#061;\u53f7\u91cd\u5199\u4e3a200&#xff0c;\u5ba2\u6237\u7aef\u770b\u5230\u6b63\u5e38\u54cd\u5e94<br \/>\nerror_page 590 &#061;200 &#064;cache_fallback_backend;<\/p>\n<p># \u2705 \u4f7f\u7528&#061;\u53f7\u91cd\u5199\u4e3a503&#xff0c;\u5ba2\u6237\u7aef\u770b\u5230\u6807\u51c6\u670d\u52a1\u4e0d\u53ef\u7528<br \/>\nerror_page 592 &#061;503 &#064;cache_static_degraded;<\/p>\n<h5>\u2462 internal\u6807\u8bb0\u9632\u6b62\u5916\u90e8\u8bbf\u95ee<\/h5>\n<p>\u6240\u6709\u964d\u7ea7location\u5fc5\u987b\u52a0\u00a0internal;&#xff0c;\u5426\u5219\u653b\u51fb\u8005\u53ef\u76f4\u63a5\u8bf7\u6c42\u00a0\/&#064;cache_fallback_backend\u00a0\u7ed5\u8fc7\u7f13\u5b58\u548c\u5b89\u5168\u68c0\u67e5\u3002<\/p>\n<hr \/>\n<h3>\u4e94\u3001\u9ad8\u7ea7\u964d\u7ea7\u6a21\u5f0f<\/h3>\n<h4>5.1 \u591a\u7ea7\u964d\u7ea7\u7011\u5e03<\/h4>\n<p>Redis\u53ef\u7528 \u2192 \u8fd4\u56de\u7f13\u5b58\u6570\u636e<br \/>\n    \u2193 (590)<br \/>\n\u6e90\u7ad9\u53ef\u7528 \u2192 \u8fd4\u56de\u5b9e\u65f6\u6570\u636e&#xff08;\u8df3\u8fc7\u7f13\u5b58&#xff09;<br \/>\n    \u2193 (592)<br \/>\n\u672c\u5730stale\u53ef\u7528 \u2192 \u8fd4\u56de\u8fc7\u671f\u6570\u636e<br \/>\n    \u2193 (stale miss)<br \/>\n\u9759\u6001\u515c\u5e95 \u2192 \u8fd4\u56de\u9884\u8bbeJSON\/HTML<br \/>\n    \u2193 (\u515c\u5e95\u5931\u8d25)<br \/>\n\u6807\u51c6503 \u2192 \u6700\u5c0f\u5316\u9519\u8bef\u54cd\u5e94<\/p>\n<p>\u5b9e\u73b0\u8981\u70b9&#xff1a;\u6bcf\u4e00\u7ea7\u964d\u7ea7\u5904\u7406\u5668\u5185\u90e8\u4ecd\u53ef\u89e6\u53d1\u4e0b\u4e00\u7ea7error_page&#xff0c;\u5f62\u6210\u94fe\u5f0f\u5bb9\u9519\u3002<\/p>\n<h4>5.2 \u57fa\u4e8eHeader\u7684\u6761\u4ef6\u964d\u7ea7<\/h4>\n<p># \u67d0\u4e9b\u63a5\u53e3\u4e0d\u5141\u8bb8\u964d\u7ea7&#xff08;\u5982\u652f\u4ed8\u3001\u9274\u6743&#xff09;<br \/>\nmap $uri $allow_degradation {<br \/>\n    ~^\/api\/payment\/    0;<br \/>\n    ~^\/api\/auth\/       0;<br \/>\n    default            1;<br \/>\n}<\/p>\n<p>server {<br \/>\n    # \u4ec5\u5141\u8bb8\u964d\u7ea7\u7684\u63a5\u53e3\u8d70error_page<br \/>\n    if ($allow_degradation &#061; 0) {<br \/>\n        set $no_fallback 1;<br \/>\n    }<\/p>\n<p>    location \/api\/ {<br \/>\n        content_by_lua_block {<br \/>\n            if ngx.var.no_fallback &#061;&#061; &#034;1&#034; then<br \/>\n                &#8212; \u7981\u7528\u964d\u7ea7&#xff0c;\u76f4\u63a5\u900f\u4f20\u9519\u8bef<br \/>\n                cache_handler.strict_mode(true)<br \/>\n            end<br \/>\n            &#8212; &#8230;\u6b63\u5e38\u903b\u8f91<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<h4>5.3 \u964d\u7ea7\u54cd\u5e94\u7684\u7f13\u5b58<\/h4>\n<p>\u964d\u7ea7\u54cd\u5e94\u672c\u8eab\u4e5f\u53ef\u4ee5\u88ab\u77ed\u6682\u7f13\u5b58&#xff0c;\u907f\u514d\u6bcf\u6b21\u8bf7\u6c42\u90fd\u6267\u884c\u964d\u7ea7\u903b\u8f91&#xff1a;<\/p>\n<p>location &#064;cache_fallback_backend {<br \/>\n    internal;<br \/>\n    proxy_pass http:\/\/backend;<\/p>\n<p>    # \u2b50 \u964d\u7ea7\u54cd\u5e94\u7f13\u5b585\u79d2&#xff0c;\u51cf\u8f7b\u6e90\u7ad9\u538b\u529b<br \/>\n    proxy_cache fallback_cache;<br \/>\n    proxy_cache_valid 200 5s;<br \/>\n    proxy_cache_key &#034;fallback:$request_uri&#034;;<br \/>\n    proxy_cache_use_stale error timeout;<br \/>\n}<\/p>\n<p>&#x1f4cc;\u00a0\u6ce8\u610f&#xff1a;\u964d\u7ea7\u7f13\u5b58\u7684TTL\u5fc5\u987b\u6781\u77ed&#xff08;\u226410s&#xff09;&#xff0c;\u5426\u5219\u4f1a\u5728\u6e90\u7ad9\u6062\u590d\u540e\u4ecd\u8fd4\u56de\u65e7\u6570\u636e&#xff0c;\u9020\u6210\u4e8c\u6b21\u4e0d\u4e00\u81f4\u3002<\/p>\n<hr \/>\n<h3>\u516d\u3001\u53ef\u89c2\u6d4b\u6027&#xff1a;\u8ba9\u964d\u7ea7\u53ef\u89c1<\/h3>\n<h4>6.1 \u964d\u7ea7\u4e8b\u4ef6\u65e5\u5fd7\u683c\u5f0f<\/h4>\n<p>log_format degradation &#039;$remote_addr [$time_local] &#034;$request&#034; &#039;<br \/>\n                       &#039;$status $body_bytes_sent &#039;<br \/>\n                       &#039;degrade_type&#061;$http_x_cache_degraded &#039;<br \/>\n                       &#039;original_status&#061;$upstream_status &#039;<br \/>\n                       &#039;response_time&#061;$request_time&#039;;<\/p>\n<p># \u4ec5\u5728\u964d\u7ea7\u65f6\u8bb0\u5f55<br \/>\nmap $http_x_cache_degraded $log_degradation {<br \/>\n    &#034;&#034;      0;<br \/>\n    default 1;<br \/>\n}<\/p>\n<p>access_log \/var\/log\/nginx\/degradation.log degradation if&#061;$log_degradation;<\/p>\n<h4>6.2 Prometheus\u6307\u6807\u66b4\u9732<\/h4>\n<p>&#8212; \u5728\u964d\u7ea7\u5904\u7406\u5668\u4e2d\u9012\u589e\u8ba1\u6570\u5668<br \/>\ncontent_by_lua_block {<br \/>\n    local metrics &#061; ngx.shared.metrics<br \/>\n    metrics:incr(&#034;cache_degradation_total&#034;, 1)<br \/>\n    metrics:incr(&#034;cache_degradation_&#034; .. ngx.var.http_x_cache_degraded, 1)<br \/>\n    &#8212; &#8230;\u6b63\u5e38\u964d\u7ea7\u903b\u8f91<br \/>\n}<\/p>\n<p>Grafana\u9762\u677f\u5e94\u5305\u542b&#xff1a;<\/p>\n<ul>\n<li>\u964d\u7ea7\u7387\u8d8b\u52bf\u7ebf&#xff08;\u6309\u7c7b\u578b\u5206\u8272&#xff09;<\/li>\n<li>\u964d\u7ea7\u6301\u7eed\u65f6\u95f4\u5206\u5e03<\/li>\n<li>\u964d\u7ea7\u671f\u95f4\u7684\u6e90\u7ad9QPS\u53d8\u5316<\/li>\n<li>\u964d\u7ea7\u6062\u590d\u65f6\u95f4&#xff08;\u4ece\u9996\u6b21\u964d\u7ea7\u5230\u5b8c\u5168\u6062\u590d&#xff09;<\/li>\n<\/ul>\n<h4>6.3 \u544a\u8b66\u89c4\u5219<\/h4>\n<p>&#8211; alert: CacheDegradationHigh<br \/>\n  expr: rate(cache_degradation_total[5m]) &gt; 100<br \/>\n  for: 1m<br \/>\n  labels:<br \/>\n    severity: critical<br \/>\n  annotations:<br \/>\n    summary: &#034;\u7f13\u5b58\u964d\u7ea7\u7387\u8d85\u8fc7100\/s&#xff0c;\u6301\u7eed1\u5206\u949f&#034;<\/p>\n<p>&#8211; alert: FullDegradationActive<br \/>\n  expr: cache_degradation_full_degradation &gt; 0<br \/>\n  for: 30s<br \/>\n  labels:<br \/>\n    severity: critical<br \/>\n  annotations:<br \/>\n    summary: &#034;\u5168\u91cf\u964d\u7ea7\u5df2\u6fc0\u6d3b&#xff0c;\u7f13\u5b58\u548c\u6e90\u7ad9\u5747\u4e0d\u53ef\u7528&#034;<\/p>\n<hr \/>\n<h3>\u4e03\u3001\u751f\u4ea7\u5b89\u5168\u68c0\u67e5\u6e05\u5355<\/h3>\n<table>\n<tr>\u68c0\u67e5\u9879\u72b6\u6001\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u6240\u6709\u964d\u7ea7location\u6807\u8bb0internal<\/td>\n<td>\u2610<\/td>\n<td>\u9632\u6b62\u5916\u90e8\u76f4\u63a5\u8bbf\u95ee<\/td>\n<\/tr>\n<tr>\n<td>error_page\u4f7f\u7528&#061;\u53f7\u91cd\u5199\u72b6\u6001\u7801<\/td>\n<td>\u2610<\/td>\n<td>\u907f\u514d\u66b4\u9732\u81ea\u5b9a\u4e49\u7801\u7ed9\u5ba2\u6237\u7aef<\/td>\n<\/tr>\n<tr>\n<td>Lua\u4e2dngx.exit\u5728\u8f93\u51fa\u524d\u8c03\u7528<\/td>\n<td>\u2610<\/td>\n<td>\u5426\u5219error_page\u4e0d\u751f\u6548<\/td>\n<\/tr>\n<tr>\n<td>\u964d\u7ea7\u8d85\u65f6\u6bd4\u6b63\u5e38\u8d85\u65f6\u77ed<\/td>\n<td>\u2610<\/td>\n<td>\u907f\u514d\u964d\u7ea7\u672c\u8eab\u6210\u4e3a\u74f6\u9888<\/td>\n<\/tr>\n<tr>\n<td>\u964d\u7ea7\u54cd\u5e94\u6709\u660e\u786e\u6807\u8bc6Header<\/td>\n<td>\u2610<\/td>\n<td>X-Cache-Degraded\u4fbf\u4e8e\u8c03\u8bd5\u548c\u76d1\u63a7<\/td>\n<\/tr>\n<tr>\n<td>\u5173\u952e\u63a5\u53e3\u7981\u7528\u964d\u7ea7<\/td>\n<td>\u2610<\/td>\n<td>\u652f\u4ed8\/\u9274\u6743\u7b49\u4e0d\u63a5\u53d7\u810f\u6570\u636e<\/td>\n<\/tr>\n<tr>\n<td>\u964d\u7ea7\u65e5\u5fd7\u72ec\u7acb\u91c7\u96c6<\/td>\n<td>\u2610<\/td>\n<td>\u4e0d\u5f71\u54cd\u6b63\u5e38access_log\u6027\u80fd<\/td>\n<\/tr>\n<tr>\n<td>\u964d\u7ea7\u6307\u6807\u63a5\u5165\u544a\u8b66<\/td>\n<td>\u2610<\/td>\n<td>\u964d\u7ea7\u662f\u4e8b\u6545&#xff0c;\u4e0d\u662f\u5e38\u6001<\/td>\n<\/tr>\n<tr>\n<td>\u5b9a\u671f\u6f14\u7ec3\u964d\u7ea7\u6d41\u7a0b<\/td>\n<td>\u2610<\/td>\n<td>\u6a21\u62dfRedis\u6545\u969c\u9a8c\u8bc1\u94fe\u8def<\/td>\n<\/tr>\n<tr>\n<td>\u515c\u5e95\u54cd\u5e94\u7ecf\u8fc7\u6d4b\u8bd5<\/td>\n<td>\u2610<\/td>\n<td>\u786e\u4fddJSON\u683c\u5f0f\u6b63\u786e\u3001\u5ba2\u6237\u7aef\u53ef\u89e3\u6790<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u516b\u3001\u5e38\u89c1\u8e29\u5751\u901f\u67e5\u8868<\/h3>\n<table>\n<tr>\u73b0\u8c61\u6839\u56e0\u89e3\u51b3\u65b9\u6848<\/tr>\n<tbody>\n<tr>\n<td>error_page\u672a\u89e6\u53d1<\/td>\n<td>Lua\u5df2\u53d1\u9001header\u540e\u624dset status<\/td>\n<td>\u9519\u8bef\u5224\u65ad\u524d\u7f6e&#xff0c;\u9996\u6b21\u8f93\u51fa\u524dexit<\/td>\n<\/tr>\n<tr>\n<td>\u5ba2\u6237\u7aef\u6536\u5230590\u72b6\u6001\u7801<\/td>\n<td>error_page\u7f3a\u5c11&#061;\u53f7\u91cd\u5199<\/td>\n<td>\u6539\u4e3aerror_page 590 &#061;200 &#064;handler<\/td>\n<\/tr>\n<tr>\n<td>\u964d\u7ea7location\u88ab\u5916\u90e8\u8bbf\u95ee<\/td>\n<td>\u7f3a\u5c11internal\u6307\u4ee4<\/td>\n<td>\u6dfb\u52a0internal;<\/td>\n<\/tr>\n<tr>\n<td>\u964d\u7ea7\u540e\u6e90\u7ad9\u88ab\u6253\u57ae<\/td>\n<td>\u964d\u7ea7\u54cd\u5e94\u672a\u505a\u77ed\u65f6\u7f13\u5b58<\/td>\n<td>\u6dfb\u52a0proxy_cache 5s<\/td>\n<\/tr>\n<tr>\n<td>\u964d\u7ea7\u65e5\u5fd7\u7f3a\u5931<\/td>\n<td>log_format\u672a\u5339\u914d\u81ea\u5b9a\u4e49Header<\/td>\n<td>\u68c0\u67e5map\u6761\u4ef6\u548c\u53d8\u91cf\u540d<\/td>\n<\/tr>\n<tr>\n<td>\u5faa\u73af\u964d\u7ea7<\/td>\n<td>\u964d\u7ea7\u5904\u7406\u5668\u5185\u90e8\u53c8\u89e6\u53d1\u76f8\u540cerror_page<\/td>\n<td>\u9650\u5236\u964d\u7ea7\u6df1\u5ea6\u6216\u4f7f\u7528\u4e0d\u540c\u9519\u8bef\u7801<\/td>\n<\/tr>\n<tr>\n<td>Lua pcall\u541e\u6389\u9519\u8bef<\/td>\n<td>pcall\u6210\u529f\u4f46\u8fd4\u56denil\u672a\u68c0\u67e5<\/td>\n<td>\u663e\u5f0f\u5224\u65ad\u8fd4\u56de\u503c\u5e76\u8bbe\u7f6engx.status<\/td>\n<\/tr>\n<tr>\n<td>\u964d\u7ea7\u54cd\u5e94\u683c\u5f0f\u9519\u8bef<\/td>\n<td>\u672a\u8bbe\u7f6edefault_type<\/td>\n<td>\u6dfb\u52a0default_type application\/json<\/td>\n<\/tr>\n<tr>\n<td>\u76d1\u63a7\u770b\u4e0d\u5230\u964d\u7ea7\u4e8b\u4ef6<\/td>\n<td>\u6307\u6807\u672a\u5728\u964d\u7ea7\u5904\u7406\u5668\u4e2d\u9012\u589e<\/td>\n<td>\u5728\u6bcf\u4e2a&#064;handler\u4e2d\u6dfb\u52a0\u8ba1\u6570\u903b\u8f91<\/td>\n<\/tr>\n<tr>\n<td>\u652f\u4ed8\u63a5\u53e3\u8fd4\u56de\u964d\u7ea7\u6570\u636e<\/td>\n<td>\u672a\u6309URI\u6392\u9664\u964d\u7ea7<\/td>\n<td>map\u914d\u7f6eno_fallback\u6807\u8bb0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u4e5d\u3001\u7ed3\u8bed<\/h3>\n<p>\u611f\u8c22\u60a8\u7684\u9605\u8bfb&#xff01;\u5982\u679c\u4f60\u6709\u4efb\u4f55\u7591\u95ee\u6216\u60f3\u8981\u5206\u4eab\u7684\u7ecf\u9a8c&#xff0c;\u8bf7\u5728\u8bc4\u8bba\u533a\u7559\u8a00\u4ea4\u6d41&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u5f15\u8a00&#xff1a;\u5f53\u7f13\u5b58\u6210\u4e3a\u6545\u969c\u6e90&#xff0c;error_page\u662f\u6700\u540e\u9632\u7ebf\u5728\u300aNginx\u5916\u7f6e\u7f13\u5b58\u300b\u7cfb\u5217\u524d\u6587\u4e2d&#xff0c;\u6211\u4eec\u6784\u5efa\u4e86\u4ee5OpenResty  Redis\u4e3a\u6838\u5fc3\u7684\u5206\u5e03\u5f0f\u7f13\u5b58\u4f53\u7cfb\u3002\u8fd9\u5957\u67b6\u6784\u5728\u6b63\u5e38\u60c5\u51b5\u4e0b\u8868\u73b0\u4f18\u5f02&#xff0c;\u4f46\u751f\u4ea7\u73af\u5883\u7684\u6b8b\u9177\u73b0\u5b9e\u662f&#xff1a;\u5916\u7f6e\u7f13\u5b58\u672c\u8eab\u53ef\u80fd\u6210\u4e3a\u6700\u5927\u7684\u5355\u70b9\u6545\u969c\u3002Redis\u96c6\u7fa4\u4e3b\u4ece\u5207\u6362\u671f\u95f4&#xff0c;\u6570\u767e\u6beb\u79d2\u7684\u5199\u5165\u963b\u585e\u5bfc\u81f4Nginx\u5927\u91cf504&#xff1b;\u7f13\u5b58\u670d\u52a1OOM\u91cd\u542f&#xff0c;\u6240\u6709\u8bf7\u6c42\u77ac\u95f4\u7a7f\u900f\u5230\u6e90\u7ad9&amp;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[117,398,44],"topic":[],"class_list":["post-87805","post","type-post","status-publish","format-standard","hentry","category-server","tag-nginx","tag-398","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Nginx\u5916\u7f6e\u7f13\u5b58-error_page - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/87805.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Nginx\u5916\u7f6e\u7f13\u5b58-error_page - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001\u5f15\u8a00&#xff1a;\u5f53\u7f13\u5b58\u6210\u4e3a\u6545\u969c\u6e90&#xff0c;error_page\u662f\u6700\u540e\u9632\u7ebf\u5728\u300aNginx\u5916\u7f6e\u7f13\u5b58\u300b\u7cfb\u5217\u524d\u6587\u4e2d&#xff0c;\u6211\u4eec\u6784\u5efa\u4e86\u4ee5OpenResty Redis\u4e3a\u6838\u5fc3\u7684\u5206\u5e03\u5f0f\u7f13\u5b58\u4f53\u7cfb\u3002\u8fd9\u5957\u67b6\u6784\u5728\u6b63\u5e38\u60c5\u51b5\u4e0b\u8868\u73b0\u4f18\u5f02&#xff0c;\u4f46\u751f\u4ea7\u73af\u5883\u7684\u6b8b\u9177\u73b0\u5b9e\u662f&#xff1a;\u5916\u7f6e\u7f13\u5b58\u672c\u8eab\u53ef\u80fd\u6210\u4e3a\u6700\u5927\u7684\u5355\u70b9\u6545\u969c\u3002Redis\u96c6\u7fa4\u4e3b\u4ece\u5207\u6362\u671f\u95f4&#xff0c;\u6570\u767e\u6beb\u79d2\u7684\u5199\u5165\u963b\u585e\u5bfc\u81f4Nginx\u5927\u91cf504&#xff1b;\u7f13\u5b58\u670d\u52a1OOM\u91cd\u542f&#xff0c;\u6240\u6709\u8bf7\u6c42\u77ac\u95f4\u7a7f\u900f\u5230\u6e90\u7ad9&amp;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/87805.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-30T14:56:33+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/87805.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/87805.html\",\"name\":\"Nginx\u5916\u7f6e\u7f13\u5b58-error_page - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-30T14:56:33+00:00\",\"dateModified\":\"2026-07-30T14:56:33+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/87805.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/87805.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/87805.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Nginx\u5916\u7f6e\u7f13\u5b58-error_page\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Nginx\u5916\u7f6e\u7f13\u5b58-error_page - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/87805.html","og_locale":"zh_CN","og_type":"article","og_title":"Nginx\u5916\u7f6e\u7f13\u5b58-error_page - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001\u5f15\u8a00&#xff1a;\u5f53\u7f13\u5b58\u6210\u4e3a\u6545\u969c\u6e90&#xff0c;error_page\u662f\u6700\u540e\u9632\u7ebf\u5728\u300aNginx\u5916\u7f6e\u7f13\u5b58\u300b\u7cfb\u5217\u524d\u6587\u4e2d&#xff0c;\u6211\u4eec\u6784\u5efa\u4e86\u4ee5OpenResty Redis\u4e3a\u6838\u5fc3\u7684\u5206\u5e03\u5f0f\u7f13\u5b58\u4f53\u7cfb\u3002\u8fd9\u5957\u67b6\u6784\u5728\u6b63\u5e38\u60c5\u51b5\u4e0b\u8868\u73b0\u4f18\u5f02&#xff0c;\u4f46\u751f\u4ea7\u73af\u5883\u7684\u6b8b\u9177\u73b0\u5b9e\u662f&#xff1a;\u5916\u7f6e\u7f13\u5b58\u672c\u8eab\u53ef\u80fd\u6210\u4e3a\u6700\u5927\u7684\u5355\u70b9\u6545\u969c\u3002Redis\u96c6\u7fa4\u4e3b\u4ece\u5207\u6362\u671f\u95f4&#xff0c;\u6570\u767e\u6beb\u79d2\u7684\u5199\u5165\u963b\u585e\u5bfc\u81f4Nginx\u5927\u91cf504&#xff1b;\u7f13\u5b58\u670d\u52a1OOM\u91cd\u542f&#xff0c;\u6240\u6709\u8bf7\u6c42\u77ac\u95f4\u7a7f\u900f\u5230\u6e90\u7ad9&amp;","og_url":"https:\/\/www.wsisp.com\/helps\/87805.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-30T14:56:33+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/87805.html","url":"https:\/\/www.wsisp.com\/helps\/87805.html","name":"Nginx\u5916\u7f6e\u7f13\u5b58-error_page - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-30T14:56:33+00:00","dateModified":"2026-07-30T14:56:33+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/87805.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/87805.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/87805.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Nginx\u5916\u7f6e\u7f13\u5b58-error_page"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/87805","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=87805"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/87805\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=87805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=87805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=87805"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=87805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}