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

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy International News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Troy Hunt's Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Attack and Defense Labs
Attack and Defense Labs
S
Secure Thoughts
V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
O
OpenAI News
Cloudbric
Cloudbric
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Help Net Security
Help Net Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tenable Blog
S
Security @ Cisco Blogs
N
News and Events Feed by Topic
The Hacker News
The Hacker News
C
CXSECURITY Database RSS Feed - CXSecurity.com
宝玉的分享
宝玉的分享
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
V
Visual Studio Blog
P
Proofpoint News Feed
Webroot Blog
Webroot Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 三生石上(FineUI控件)
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
L
LangChain Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东

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 重写规则

正则表达式