This commit is contained in:
colben 2024-11-25 22:34:03 +08:00
parent 9cb4dedd8e
commit 3d05bc7f8c

View File

@ -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 永久重定向