惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
The Register - Security
The Register - Security
Stack Overflow Blog
Stack Overflow Blog
博客园 - 三生石上(FineUI控件)
T
Threat Research - Cisco Blogs
S
SegmentFault 最新的问题
V2EX - 技术
V2EX - 技术
Hacker News: Ask HN
Hacker News: Ask HN
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
P
Proofpoint News Feed
J
Java Code Geeks
Microsoft Security Blog
Microsoft Security Blog
M
MIT News - Artificial intelligence
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
B
Blog
N
News and Events Feed by Topic
N
News | PayPal Newsroom
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
C
Cybersecurity and Infrastructure Security Agency CISA
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
U
Unit 42
腾讯CDC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
H
Help Net Security
Recent Announcements
Recent Announcements
P
Privacy & Cybersecurity Law Blog
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Archives - TechRepublic
Security Archives - TechRepublic
L
LINUX DO - 热门话题
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
H
Heimdal Security Blog
博客园 - 聂微东
S
Securelist
大猫的无限游戏
大猫的无限游戏
Cloudbric
Cloudbric
Cisco Talos Blog
Cisco Talos Blog

nginx on 打工人日志

使用TLSv1.3 升级nginx和openssl nginx 配置和编译 nginx ssh-key connection exception nginx 编译参数详解 nginx.conf 配置文件详解 nginx 日志格式整理 nginx 汇总
nginx 重写规则 rewrite模块
2021-12-24 · via nginx on 打工人日志

nginx 重写规则 rewrite 模块

语法

语法默认值使用字段作用
breaknoneserver, location, if完成当前设置的重写规则,停止执行其他的重写规则。
set variable valuenoneserver, location, if为给定的变量设置一个特定值。
return codenoneserver, location, if停止处理并为客户端返回状态码。非标准的 444 状态码将关闭连接,不发送任何响应头。可以使用的状态码有:204,400,402-406,408,410, 411, 413, 416 与 500-504。如果状态码附带文字段落,该文本将被放置在响应主体。相反,如果状态码后面是一个 URL,该 URL 将成为 location 头补值。没有状态码的 URL 将被视为一个 302 状态码。
rewrite_log onrewrite_log offserver, location, if启用时将在 error log 中记录 notice 级别的重写日志。
rewrite regex replacement flagnoneserver, location, if按照相关的正则表达式与字符串修改 URI,指令按照在配置文件中出现的顺序执行。可以在重写指令后面添加标记。注意:如果替换的字符串以 http://开头,请求将被重定向,并且不再执行多余的 rewrite 指令。尾部的标记(flag)可以是以下的值:last – 停止处理重写模块指令,之后搜索 location 与更改后的 URI 匹配.break – 完成重写指令。redirect – 返回 302 临时重定向,如果替换字段用 http://开头则被使用。permanent – 返回 301 永久重定向。
if (condition) { … }noneserver, location尽量考虑使用 trp_files 代替。判断的条件可以有以下值
  1. 一个变量的名称:空字符传”“或者一些“0”开始的字符串为 false。
  2. 字符串比较:使用=或!=运算符
  3. 正则表达式匹配:使用~(区分大小写)和~(不区分大小写),取反运算!~和!~
  4. 文件是否存在:使用-f 和!-f 操作符
  5. 目录是否存在:使用-d 和!-d 操作符
  6. 文件、目录、符号链接是否存在:使用-e 和!-e 操作符
  7. 文件是否可执行:使用-x 和!-x 操作符'|

rewrite 重写规则

正则表达式