From 3d05bc7f8c8d2975a6858f085c840c0dfba3333f Mon Sep 17 00:00:00 2001 From: colben Date: Mon, 25 Nov 2024 22:34:03 +0800 Subject: [PATCH] update --- content/post/nginx.md | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/content/post/nginx.md b/content/post/nginx.md index 9c4070d..579e53c 100644 --- a/content/post/nginx.md +++ b/content/post/nginx.md @@ -1,7 +1,7 @@ --- title: "Nginx 笔记" date: 2019-10-30T11:47:55+08:00 -lastmod: 2019-10-30T11:47:55+08:00 +lastmod: 2024-11-25T22:23:00+08:00 tags: ["nginx", "https", "ssl", "反向代理"] categories: ["web"] --- @@ -32,10 +32,24 @@ categories: ["web"] - $document_uri $uri 不带请求参数的当前URI,不包含主机名,如"/foo/bar.html" ## rewrite -- rewrite {url正则} {replacement} {flag}; -- flag - - last 完成 rewrite,重新开始匹配 - - break 重写后不再匹配后续 rewrite +- rewrite {url正则} {replacement} {last|break|redirect|permanent}; + +### location {} 外 +- break 和 last 一样,只终止后续 server 级别的 rewrite + +### location {} 内 +- last + - 屏蔽当前 location {} 内的 root 和 proxy_pass + - 终止当前 location {} 内后续的 rewrite + - 尝试匹配其他 location {} + - 尝试执行 server 级别的 root + +- break + - 终止当前 location {} 内后续的 rewrite + - 尝试执行当前 location {} 内的 proxy_pass + - 尝试执行当前 location {} 内的 root + +### 重新发起请求 - redirect 返回 302 临时重定向 - permanent 返回 301 永久重定向