{"id":35029,"date":"2025-05-02T01:50:45","date_gmt":"2025-05-01T17:50:45","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/35029.html"},"modified":"2025-05-02T01:50:45","modified_gmt":"2025-05-01T17:50:45","slug":"%e3%80%90%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9f%a5%e8%af%86%e3%80%91nginx%e8%b7%af%e7%94%b1%e5%8c%b9%e9%85%8d%e8%a7%84%e5%88%99%e8%af%b4%e6%98%8e","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/35029.html","title":{"rendered":"\u3010\u670d\u52a1\u5668\u77e5\u8bc6\u3011Nginx\u8def\u7531\u5339\u914d\u89c4\u5219\u8bf4\u660e"},"content":{"rendered":"<\/p>\n<h4>Nginx\u8def\u7531\u5339\u914d\u89c4\u5219\u8bf4\u660e<\/h4>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>**\u4e00\u3001Nginx\u8def\u7531\u5339\u914d\u6838\u5fc3\u673a\u5236**<\/li>\n<li>**\u4e8c\u3001\u5339\u914d\u89c4\u5219\u8bed\u6cd5\u8be6\u89e3**<\/li>\n<li>\n<ul>\n<li>1. **\u7cbe\u786e\u5339\u914d (&#096;&#061;&#096;)**<\/li>\n<li>2. **\u524d\u7f00\u5339\u914d (&#096;^~&#096; \u6216 &#096;\/&#096;)**<\/li>\n<li>3. **\u6b63\u5219\u5339\u914d (&#096;~&#096; \u6216 &#096;~*&#096;)**<\/li>\n<li>4. **\u901a\u914d\u7b26\u5339\u914d (&#096;*&#096;)**<\/li>\n<\/ul>\n<\/li>\n<li>**\u4e09\u3001\u8def\u7531\u5339\u914d\u4f18\u5148\u7ea7\u987a\u5e8f**<\/li>\n<li>**\u56db\u3001\u9ad8\u7ea7\u8def\u7531\u6280\u5de7**<\/li>\n<li>\n<ul>\n<li>1. **\u6761\u4ef6\u5224\u65ad (&#096;if&#096;\u8bed\u53e5)**<\/li>\n<li>2. **\u8def\u5f84\u91cd\u5199 (&#096;rewrite&#096;\u6307\u4ee4)**<\/li>\n<li>3. **\u8d1f\u8f7d\u5747\u8861\u8def\u7531**<\/li>\n<\/ul>\n<\/li>\n<li>**\u4e94\u3001\u5b9e\u6218\u6848\u4f8b&#xff1a;\u591a\u7248\u672cAPI\u8def\u7531**<\/li>\n<li>\n<ul>\n<li>**\u9700\u6c42**&#xff1a;<\/li>\n<li>**\u914d\u7f6e**&#xff1a;<\/li>\n<\/ul>\n<\/li>\n<li>**\u516d\u3001\u5e38\u89c1\u9677\u9631\u4e0e\u8c03\u8bd5**<\/li>\n<li>\n<ul>\n<li>1. **\u4f18\u5148\u7ea7\u9519\u8bef**<\/li>\n<li>2. **\u6b63\u5219\u8868\u8fbe\u5f0f\u6027\u80fd**<\/li>\n<li>3. **\u65e5\u5fd7\u8c03\u8bd5**<\/li>\n<\/ul>\n<\/li>\n<li>**\u4e03\u3001\u603b\u7ed3**<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p> \u4ee5\u4e0b\u662fNginx\u8def\u7531\u5339\u914d\u89c4\u5219\u7684\u8be6\u7ec6\u89e3\u6790&#xff0c;\u5305\u542b\u4f18\u5148\u7ea7\u3001\u5339\u914d\u8bed\u6cd5\u3001\u5b9e\u6218\u6848\u4f8b\u53ca\u5e38\u89c1\u9677\u9631&#xff1a; <\/p>\n<h4>\u4e00\u3001Nginx\u8def\u7531\u5339\u914d\u6838\u5fc3\u673a\u5236<\/h4>\n<p>Nginx\u901a\u8fc7location\u6307\u4ee4\u5b9a\u4e49\u8def\u7531\u89c4\u5219&#xff0c;\u5339\u914d\u987a\u5e8f\u57fa\u4e8e\u4f18\u5148\u7ea7&#xff0c;\u5177\u4f53\u89c4\u5219\u5982\u4e0b&#xff1a;<\/p>\n<table>\n<tr>\u4f18\u5148\u7ea7\u7ea7\u522b\u5339\u914d\u89c4\u5219\u793a\u4f8b\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u6700\u9ad8\u4f18\u5148\u7ea7<\/td>\n<td>&#061;&#xff08;\u7cbe\u786e\u5339\u914d&#xff09;<\/td>\n<td>location &#061; \/api\/v1\/<\/td>\n<td>\u53ea\u5339\u914d\u5b8c\u5168\u5339\u914d\u7684URI&#xff0c;\u4f18\u5148\u7ea7\u6700\u9ad8<\/td>\n<\/tr>\n<tr>\n<td>\u6b21\u9ad8\u4f18\u5148\u7ea7<\/td>\n<td>^~&#xff08;\u524d\u7f00\u5339\u914d&#xff0c;\u6700\u957f\u5339\u914d&#xff09;<\/td>\n<td>location ^~ \/api\/<\/td>\n<td>\u5339\u914d\u4ee5\/api\/\u5f00\u5934\u7684URI&#xff0c;\u4e14\u9009\u62e9\u6700\u957f\u7684\u5339\u914d\u8def\u5f84<\/td>\n<\/tr>\n<tr>\n<td>\u7b2c\u4e09\u4f18\u5148\u7ea7<\/td>\n<td>~&#xff08;\u6b63\u5219\u5339\u914d&#xff09;<\/td>\n<td>&#096;location ~* .(jpg<\/td>\n<td>css)$&#096;<\/td>\n<\/tr>\n<tr>\n<td>\u6700\u4f4e\u4f18\u5148\u7ea7<\/td>\n<td>\u901a\u914d\u7b26*&#xff08;\u6a21\u7cca\u5339\u914d&#xff09;<\/td>\n<td>location \/files\/.*<\/td>\n<td>\u5339\u914d\u4ee5\/files\/\u5f00\u5934\u7684\u4efb\u610f\u8def\u5f84<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u4e8c\u3001\u5339\u914d\u89c4\u5219\u8bed\u6cd5\u8be6\u89e3<\/h4>\n<h5>1. \u7cbe\u786e\u5339\u914d (&#061;)<\/h5>\n<p>\u2022 \u8bed\u6cd5&#xff1a;location &#061; \/path\/ { &#8230; } \u2022 \u7279\u70b9&#xff1a;\u4ec5\u5339\u914d\u5b8c\u5168\u76f8\u540c\u7684URI&#xff0c;\u4f18\u5148\u7ea7\u6700\u9ad8\u3002 \u2022 \u6848\u4f8b&#xff1a;<\/p>\n<p>location &#061; \/login {<br \/>\n    proxy_pass http:\/\/backend\/login;<br \/>\n}<\/p>\n<p>\u2022 \u53ea\u6709\u8bf7\u6c42\/login\u65f6\u4f1a\u89e6\u53d1\u8be5\u89c4\u5219&#xff0c;\/login\/api\u4e0d\u4f1a\u5339\u914d\u3002<\/p>\n<h5>2. \u524d\u7f00\u5339\u914d (^~ \u6216 \/)<\/h5>\n<p>\u2022 \u8bed\u6cd5&#xff1a;location ^~ \/api\/ { &#8230; } \u6216 location \/api\/ { &#8230; } \u2022 \u7279\u70b9&#xff1a; \u2022 ^~\u8868\u793a\u4e25\u683c\u524d\u7f00\u5339\u914d&#xff0c;\u6700\u957f\u5339\u914d\u4f18\u5148\u3002 \u2022 \u5355\u659c\u6760\/\u7b49\u540c\u4e8e^~ \/&#xff0c;\u4f46\u4f18\u5148\u7ea7\u4f4e\u4e8e^~\u3002 \u2022 \u6848\u4f8b&#xff1a;<\/p>\n<p>location ^~ \/api\/v1\/ {<br \/>\n    proxy_pass http:\/\/v1-backend;<br \/>\n}<br \/>\nlocation ^~ \/api\/v2\/ {<br \/>\n    proxy_pass http:\/\/v2-backend;<br \/>\n}<\/p>\n<p>\u2022 \u8bf7\u6c42\/api\/v1\/test\u5339\u914d\u7b2c\u4e00\u4e2a\u89c4\u5219&#xff0c;\/api\/v1\/old\u5339\u914d\u6700\u957f\u8def\u5f84\u3002<\/p>\n<h5>3. \u6b63\u5219\u5339\u914d (~ \u6216 ~*)<\/h5>\n<p>\u2022 \u8bed\u6cd5&#xff1a; \u2022 ~&#xff1a;\u533a\u5206\u5927\u5c0f\u5199\u7684\u6b63\u5219\u5339\u914d \u2022 ~*&#xff1a;\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u7684\u6b63\u5219\u5339\u914d \u2022 \u793a\u4f8b&#xff1a;<\/p>\n<p># \u5339\u914d\u6240\u6709\u4ee5.jpg\u6216.png\u7ed3\u5c3e\u7684\u8bf7\u6c42&#xff08;\u4e0d\u533a\u5206\u5927\u5c0f\u5199&#xff09;<br \/>\nlocation ~* \\\\.(jpg|jpeg|png)$ {<br \/>\n    expires 30d;<br \/>\n}<\/p>\n<p>\u2022 \u6b63\u5219\u8868\u8fbe\u5f0f\u9700\u7528^\u548c$\u5305\u88f9\u4ee5\u660e\u786e\u5339\u914d\u8303\u56f4\u3002<\/p>\n<h5>4. \u901a\u914d\u7b26\u5339\u914d (*)<\/h5>\n<p>\u2022 \u8bed\u6cd5&#xff1a;location \/path\/*\/file.html { &#8230; } \u2022 \u7279\u70b9&#xff1a; \u2022 *\u5339\u914d\u4efb\u610f\u5b57\u7b26&#xff08;\u9664\u659c\u6760&#xff09;\u96f6\u6b21\u6216\u591a\u6b21\u3002 \u2022 \u4f18\u5148\u7ea7\u6700\u4f4e&#xff0c;\u4ec5\u5f53\u524d\u9762\u89c4\u5219\u672a\u5339\u914d\u65f6\u751f\u6548\u3002 \u2022 \u6848\u4f8b&#xff1a;<\/p>\n<p>location \/static\/* {<br \/>\n    alias \/var\/www\/static\/;<br \/>\n}<\/p>\n<p>\u2022 \u8bf7\u6c42\/static\/image.jpg\u4f1a\u88ab\u6620\u5c04\u5230\/var\/www\/static\/image.jpg\u3002<\/p>\n<h4>\u4e09\u3001\u8def\u7531\u5339\u914d\u4f18\u5148\u7ea7\u987a\u5e8f<\/h4>\n<p>Nginx\u7684\u8def\u7531\u5339\u914d\u4e25\u683c\u9075\u5faa\u4f18\u5148\u7ea7\u987a\u5e8f&#xff1a;<\/p>\n<p>1. &#061; \u7cbe\u786e\u5339\u914d<br \/>\n2. ^~ \u524d\u7f00\u5339\u914d&#xff08;\u6700\u957f\u5339\u914d&#xff09;<br \/>\n3. ~ \u6b63\u5219\u5339\u914d&#xff08;\u533a\u5206\u5927\u5c0f\u5199&#xff09;<br \/>\n4. ~* \u6b63\u5219\u5339\u914d&#xff08;\u4e0d\u533a\u5206\u5927\u5c0f\u5199&#xff09;<br \/>\n5. \u901a\u914d\u7b26 *<\/p>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p>location \/api\/ {<br \/>\n    # \u4f18\u5148\u7ea74&#xff08;\u901a\u914d\u7b26&#xff09;<br \/>\n}<\/p>\n<p>location ^~ \/api\/v1\/ {<br \/>\n    # \u4f18\u5148\u7ea72&#xff08;\u524d\u7f00\u5339\u914d&#xff09;&#xff0c;\u5339\u914d\/api\/v1\/\u53ca\u5176\u5b50\u8def\u5f84<br \/>\n}<\/p>\n<p>location ~* \\\\.json$ {<br \/>\n    # \u4f18\u5148\u7ea73&#xff08;\u6b63\u5219&#xff09;&#xff0c;\u5339\u914d\u6240\u6709.json\u6587\u4ef6<br \/>\n}<\/p>\n<p>\u2022 \u8bf7\u6c42\/api\/v1\/data.json\u4f1a\u5339\u914d^~ \/api\/v1\/&#xff0c;\u800c\u975e\u6b63\u5219\u89c4\u5219\u3002<\/p>\n<h4>\u56db\u3001\u9ad8\u7ea7\u8def\u7531\u6280\u5de7<\/h4>\n<h5>1. \u6761\u4ef6\u5224\u65ad (if\u8bed\u53e5)<\/h5>\n<p>\u2022 \u8bed\u6cd5&#xff1a;<\/p>\n<p>location \/user\/ {<br \/>\n    if ($arg_version &#061; &#034;v2&#034;) {<br \/>\n        proxy_pass http:\/\/v2-user-service;<br \/>\n    }<br \/>\n    default_type text\/html;<br \/>\n    return 404;<br \/>\n}<\/p>\n<p>\u2022 \u6ce8\u610f&#xff1a;\u907f\u514d\u5728location\u5757\u5185\u4f7f\u7528\u590d\u6742\u6761\u4ef6\u5224\u65ad&#xff0c;\u53ef\u80fd\u5bfc\u81f4\u6027\u80fd\u95ee\u9898\u3002<\/p>\n<h5>2. \u8def\u5f84\u91cd\u5199 (rewrite\u6307\u4ee4)<\/h5>\n<p>\u2022 \u8bed\u6cd5&#xff1a;<\/p>\n<p>location \/old-path\/ {<br \/>\n    rewrite ^\/old-path\/(.*)$ \/new-path\/$1 permanent;<br \/>\n}<\/p>\n<p>\u2022 \u4f5c\u7528&#xff1a;\u5c06\/old-path\/user\u91cd\u5b9a\u5411\u5230\/new-path\/user\u3002<\/p>\n<h5>3. \u8d1f\u8f7d\u5747\u8861\u8def\u7531<\/h5>\n<p>\u2022 \u8bed\u6cd5&#xff1a;<\/p>\n<p>upstream backend {<br \/>\n    server backend1.example.com;<br \/>\n    server backend2.example.com;<br \/>\n}<\/p>\n<p>location \/api\/ {<br \/>\n    proxy_pass http:\/\/backend;<br \/>\n}<\/p>\n<p>\u2022 \u6269\u5c55&#xff1a;\u7ed3\u5408upstream\u6a21\u5757\u5b9e\u73b0\u52a0\u6743\u8f6e\u8be2\u3001IP\u54c8\u5e0c\u7b49\u7b56\u7565\u3002<\/p>\n<h4>\u4e94\u3001\u5b9e\u6218\u6848\u4f8b&#xff1a;\u591a\u7248\u672cAPI\u8def\u7531<\/h4>\n<h5>\u9700\u6c42&#xff1a;<\/h5>\n<p>\u2022 \/api\/v1\/* \u2192 \u7248\u672c1 \u2022 \/api\/v2\/* \u2192 \u7248\u672c2 \u2022 \/admin\/* \u2192 \u7ba1\u7406\u540e\u53f0<\/p>\n<h5>\u914d\u7f6e&#xff1a;<\/h5>\n<p># \u6700\u9ad8\u4f18\u5148\u7ea7&#xff1a;\u7cbe\u786e\u5339\u914d\/admin\/<br \/>\nlocation &#061; \/admin\/ {<br \/>\n    proxy_pass http:\/\/admin-backend;<br \/>\n}<\/p>\n<p># \u524d\u7f00\u5339\u914d\/api\/v1\/ \u548c \/api\/v2\/<br \/>\nlocation ^~ \/api\/v1\/ {<br \/>\n    proxy_pass http:\/\/v1-api;<br \/>\n}<\/p>\n<p>location ^~ \/api\/v2\/ {<br \/>\n    proxy_pass http:\/\/v2-api;<br \/>\n}<\/p>\n<p># \u901a\u914d\u7b26\u5339\u914d\u5176\u4ed6\/api\u8bf7\u6c42&#xff08;\u515c\u5e95&#xff09;<br \/>\nlocation \/api\/ {<br \/>\n    proxy_pass http:\/\/default-api;<br \/>\n}<\/p>\n<h4>\u516d\u3001\u5e38\u89c1\u9677\u9631\u4e0e\u8c03\u8bd5<\/h4>\n<h5>1. \u4f18\u5148\u7ea7\u9519\u8bef<\/h5>\n<p>\u2022 \u95ee\u9898&#xff1a;\u8bef\u5c06\u901a\u914d\u7b26\u89c4\u5219\u653e\u5728^~\u89c4\u5219\u524d\u3002 \u2022 \u4fee\u590d&#xff1a;\u68c0\u67e5location\u5757\u7684\u987a\u5e8f&#xff0c;\u786e\u4fdd\u9ad8\u4f18\u5148\u7ea7\u89c4\u5219\u5728\u524d\u3002<\/p>\n<h5>2. \u6b63\u5219\u8868\u8fbe\u5f0f\u6027\u80fd<\/h5>\n<p>\u2022 \u95ee\u9898&#xff1a;\u4f7f\u7528\u4f4e\u6548\u7684\u6b63\u5219\u8868\u8fbe\u5f0f&#xff08;\u5982.*\u5f00\u5934&#xff09;\u5bfc\u81f4\u5339\u914d\u7f13\u6162\u3002 \u2022 \u4f18\u5316&#xff1a;\u5c3d\u53ef\u80fd\u4f7f\u7528\u5177\u4f53\u524d\u7f00&#xff08;\u5982~* \\\\.(jpg|css)$\u4ee3\u66ff~* .*$&#xff09;\u3002<\/p>\n<h5>3. \u65e5\u5fd7\u8c03\u8bd5<\/h5>\n<p>\u2022 \u6307\u4ee4&#xff1a;<\/p>\n<p>error_log \/var\/log\/nginx\/error.log warn;<br \/>\naccess_log \/var\/log\/nginx\/access.log;<\/p>\n<p>\u2022 \u8c03\u8bd5\u547d\u4ee4&#xff1a;<\/p>\n<p>nginx <span class=\"token parameter variable\">-t<\/span>            <span class=\"token comment\"># \u6d4b\u8bd5\u914d\u7f6e\u8bed\u6cd5<\/span><br \/>\nnginx <span class=\"token parameter variable\">-s<\/span> reload     <span class=\"token comment\"># \u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e<\/span><br \/>\n<span class=\"token function\">curl<\/span> <span class=\"token parameter variable\">-I<\/span> http:\/\/localhost\/test  <span class=\"token comment\"># \u67e5\u770b\u54cd\u5e94\u5934<\/span><\/p>\n<h4>\u4e03\u3001\u603b\u7ed3<\/h4>\n<p>Nginx\u8def\u7531\u5339\u914d\u7684\u6838\u5fc3\u662f\u4f18\u5148\u7ea7\u987a\u5e8f\u548c\u89c4\u5219\u8bed\u6cd5\u7684\u6b63\u786e\u7ec4\u5408&#xff1a;<\/p>\n<li>\u4f18\u5148\u4f7f\u7528^~\u524d\u7f00\u5339\u914d\u5b9e\u73b0\u7248\u672c\u8def\u7531\u3002<\/li>\n<li>**\u6b63\u5219\u5339\u914d~***\u5904\u7406\u52a8\u6001\u8def\u5f84&#xff08;\u5982\u6587\u4ef6\u7c7b\u578b&#xff09;\u3002<\/li>\n<li>**\u901a\u914d\u7b26***\u4f5c\u4e3a\u515c\u5e95\u89c4\u5219\u3002<\/li>\n<li>\u907f\u514d\u5728location\u5757\u5185\u5d4c\u5957\u590d\u6742\u903b\u8f91&#xff0c;\u4fdd\u6301\u914d\u7f6e\u7b80\u6d01\u3002<\/li>\n<p>\u901a\u8fc7\u5408\u7406\u5229\u7528\u8fd9\u4e9b\u89c4\u5219&#xff0c;\u53ef\u4ee5\u5b9e\u73b0\u7075\u6d3b\u3001\u9ad8\u6548\u7684\u8def\u7531\u7b56\u7565&#xff0c;\u652f\u6491\u5fae\u670d\u52a1\u67b6\u6784\u7684\u6d41\u91cf\u6cbb\u7406\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb732\u6b21\uff0c\u70b9\u8d5e11\u6b21\uff0c\u6536\u85cf4\u6b21\u3002\u901a\u8fc7\u5408\u7406\u5229\u7528\u8fd9\u4e9b\u8def\u5f84\u5339\u914d\u89c4\u5219\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u63a7\u5236\u5bf9\u4e0d\u540c\u8d44\u6e90\u7684\u8bbf\u95ee\uff0c\u4f18\u5316\u8d44\u6e90\u52a0\u8f7d\u901f\u5ea6\uff0c\u5e76\u589e\u5f3a\u5b89\u5168\u6027\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u7528\u5b83\u6765\u8bbe\u7f6e\u7f13\u5b58\u7b56\u7565\u3001\u9650\u5236\u8bbf\u95ee\u6743\u9650\u6216\u662f\u91cd\u5b9a\u5411\u7279\u5b9a\u7684\u8bf7\u6c42\u7b49\u3002\u6307\u4ee4\u6765\u5b9a\u4e49\u5982\u4f55\u5904\u7406\u4e0d\u540c\u7684URL\u8bf7\u6c42\u3002\u7406\u89e3\u8fd9\u4e9b\u89c4\u5219\u5bf9\u4e8e\u914d\u7f6e\u9ad8\u6548\u3001\u5b89\u5168\u7684Web\u670d\u52a1\u5668\u81f3\u5173\u91cd\u8981\u3002Nginx \u63d0\u4f9b\u4e86\u7075\u6d3b\u7684\u8def\u5f84\u5339\u914d\u89c4\u5219\uff0c\u901a\u8fc7\u3002\u4e2d\u5b9e\u73b0\uff0c\u4f46\u53ef\u4ee5\u901a\u8fc7\u6761\u4ef6\u5224\u65ad\u5b9e\u73b0\u7c7b\u4f3c\u6548\u679c\u3002\uff08\u9ed8\u8ba4\uff09\uff1a\u6ca1\u6709\u4fee\u9970\u7b26\u7684\u60c5\u51b5\u3002\uff08\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff09\u4f5c\u4e3a\u524d\u7f00\u3002_nginx\u8def\u7531\u5339\u914d\u89c4\u5219<\/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,43,867,78],"topic":[],"class_list":["post-35029","post","type-post","status-publish","format-standard","hentry","category-server","tag-nginx","tag-43","tag-867","tag-78"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010\u670d\u52a1\u5668\u77e5\u8bc6\u3011Nginx\u8def\u7531\u5339\u914d\u89c4\u5219\u8bf4\u660e - \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\/35029.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010\u670d\u52a1\u5668\u77e5\u8bc6\u3011Nginx\u8def\u7531\u5339\u914d\u89c4\u5219\u8bf4\u660e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb732\u6b21\uff0c\u70b9\u8d5e11\u6b21\uff0c\u6536\u85cf4\u6b21\u3002\u901a\u8fc7\u5408\u7406\u5229\u7528\u8fd9\u4e9b\u8def\u5f84\u5339\u914d\u89c4\u5219\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u63a7\u5236\u5bf9\u4e0d\u540c\u8d44\u6e90\u7684\u8bbf\u95ee\uff0c\u4f18\u5316\u8d44\u6e90\u52a0\u8f7d\u901f\u5ea6\uff0c\u5e76\u589e\u5f3a\u5b89\u5168\u6027\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u7528\u5b83\u6765\u8bbe\u7f6e\u7f13\u5b58\u7b56\u7565\u3001\u9650\u5236\u8bbf\u95ee\u6743\u9650\u6216\u662f\u91cd\u5b9a\u5411\u7279\u5b9a\u7684\u8bf7\u6c42\u7b49\u3002\u6307\u4ee4\u6765\u5b9a\u4e49\u5982\u4f55\u5904\u7406\u4e0d\u540c\u7684URL\u8bf7\u6c42\u3002\u7406\u89e3\u8fd9\u4e9b\u89c4\u5219\u5bf9\u4e8e\u914d\u7f6e\u9ad8\u6548\u3001\u5b89\u5168\u7684Web\u670d\u52a1\u5668\u81f3\u5173\u91cd\u8981\u3002Nginx \u63d0\u4f9b\u4e86\u7075\u6d3b\u7684\u8def\u5f84\u5339\u914d\u89c4\u5219\uff0c\u901a\u8fc7\u3002\u4e2d\u5b9e\u73b0\uff0c\u4f46\u53ef\u4ee5\u901a\u8fc7\u6761\u4ef6\u5224\u65ad\u5b9e\u73b0\u7c7b\u4f3c\u6548\u679c\u3002\uff08\u9ed8\u8ba4\uff09\uff1a\u6ca1\u6709\u4fee\u9970\u7b26\u7684\u60c5\u51b5\u3002\uff08\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff09\u4f5c\u4e3a\u524d\u7f00\u3002_nginx\u8def\u7531\u5339\u914d\u89c4\u5219\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/35029.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-01T17:50:45+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=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/35029.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/35029.html\",\"name\":\"\u3010\u670d\u52a1\u5668\u77e5\u8bc6\u3011Nginx\u8def\u7531\u5339\u914d\u89c4\u5219\u8bf4\u660e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-01T17:50:45+00:00\",\"dateModified\":\"2025-05-01T17:50:45+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/35029.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/35029.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/35029.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010\u670d\u52a1\u5668\u77e5\u8bc6\u3011Nginx\u8def\u7531\u5339\u914d\u89c4\u5219\u8bf4\u660e\"}]},{\"@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":"\u3010\u670d\u52a1\u5668\u77e5\u8bc6\u3011Nginx\u8def\u7531\u5339\u914d\u89c4\u5219\u8bf4\u660e - \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\/35029.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010\u670d\u52a1\u5668\u77e5\u8bc6\u3011Nginx\u8def\u7531\u5339\u914d\u89c4\u5219\u8bf4\u660e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb732\u6b21\uff0c\u70b9\u8d5e11\u6b21\uff0c\u6536\u85cf4\u6b21\u3002\u901a\u8fc7\u5408\u7406\u5229\u7528\u8fd9\u4e9b\u8def\u5f84\u5339\u914d\u89c4\u5219\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u63a7\u5236\u5bf9\u4e0d\u540c\u8d44\u6e90\u7684\u8bbf\u95ee\uff0c\u4f18\u5316\u8d44\u6e90\u52a0\u8f7d\u901f\u5ea6\uff0c\u5e76\u589e\u5f3a\u5b89\u5168\u6027\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u7528\u5b83\u6765\u8bbe\u7f6e\u7f13\u5b58\u7b56\u7565\u3001\u9650\u5236\u8bbf\u95ee\u6743\u9650\u6216\u662f\u91cd\u5b9a\u5411\u7279\u5b9a\u7684\u8bf7\u6c42\u7b49\u3002\u6307\u4ee4\u6765\u5b9a\u4e49\u5982\u4f55\u5904\u7406\u4e0d\u540c\u7684URL\u8bf7\u6c42\u3002\u7406\u89e3\u8fd9\u4e9b\u89c4\u5219\u5bf9\u4e8e\u914d\u7f6e\u9ad8\u6548\u3001\u5b89\u5168\u7684Web\u670d\u52a1\u5668\u81f3\u5173\u91cd\u8981\u3002Nginx \u63d0\u4f9b\u4e86\u7075\u6d3b\u7684\u8def\u5f84\u5339\u914d\u89c4\u5219\uff0c\u901a\u8fc7\u3002\u4e2d\u5b9e\u73b0\uff0c\u4f46\u53ef\u4ee5\u901a\u8fc7\u6761\u4ef6\u5224\u65ad\u5b9e\u73b0\u7c7b\u4f3c\u6548\u679c\u3002\uff08\u9ed8\u8ba4\uff09\uff1a\u6ca1\u6709\u4fee\u9970\u7b26\u7684\u60c5\u51b5\u3002\uff08\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff09\u4f5c\u4e3a\u524d\u7f00\u3002_nginx\u8def\u7531\u5339\u914d\u89c4\u5219","og_url":"https:\/\/www.wsisp.com\/helps\/35029.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-01T17:50:45+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/35029.html","url":"https:\/\/www.wsisp.com\/helps\/35029.html","name":"\u3010\u670d\u52a1\u5668\u77e5\u8bc6\u3011Nginx\u8def\u7531\u5339\u914d\u89c4\u5219\u8bf4\u660e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-01T17:50:45+00:00","dateModified":"2025-05-01T17:50:45+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/35029.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/35029.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/35029.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010\u670d\u52a1\u5668\u77e5\u8bc6\u3011Nginx\u8def\u7531\u5339\u914d\u89c4\u5219\u8bf4\u660e"}]},{"@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\/35029","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=35029"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/35029\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=35029"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=35029"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=35029"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=35029"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}