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

推荐订阅源

H
Help Net Security
C
Cybersecurity and Infrastructure Security Agency CISA
S
Secure Thoughts
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hacker News: Ask HN
Hacker News: Ask HN
Attack and Defense Labs
Attack and Defense Labs
N
News and Events Feed by Topic
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
A
Arctic Wolf
www.infosecurity-magazine.com
www.infosecurity-magazine.com
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The GitHub Blog
The GitHub Blog
W
WeLiveSecurity
Simon Willison's Weblog
Simon Willison's Weblog
WordPress大学
WordPress大学
Y
Y Combinator Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Forbes - Security
Forbes - Security
NISL@THU
NISL@THU
博客园 - 聂微东
G
Google Developers Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Schneier on Security
Schneier on Security
V
Vulnerabilities – Threatpost
V
V2EX
I
Intezer
S
Schneier on Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
雷峰网
雷峰网
L
LangChain Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
L
LINUX DO - 热门话题
P
Proofpoint News Feed
Microsoft Security Blog
Microsoft Security Blog
Project Zero
Project Zero
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
爱范儿
爱范儿
H
Hacker News: Front Page
B
Blog
T
Threatpost
Spread Privacy
Spread Privacy
H
Heimdal Security Blog
F
Fortinet All Blogs
TaoSecurity Blog
TaoSecurity Blog
T
Threat Research - Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
The Cloudflare Blog

NGINX

有用 Nginx UI 的朋友吗?这玩意是不是时不时将磁盘 IO 打满? fail2ban 保护 nginx 方案 - V2EX 麦当劳服务模式是 nginx,肯德基服务模式是 apache,这样理解对不对? - V2EX oracleusa.ml 的实现原理 - V2EX 尝试自己配置转发后端请求的时候有个疑问 - V2EX 请教 Nginx 时完整的 SSL 刷新教程或者脚本 - V2EX 问问大家 nginx 日志流量分析用什么方案? - V2EX nginx 二级目录反向代理是不是有先天缺陷? - V2EX 问个 nginx 配置问题 - V2EX 请问下为啥微信客户端访问到 nginx 没有参数了? - V2EX 有兄弟们用 nginx proxy manager(或者其他图形化工具)来管理 nginx 反向代理的吗? - V2EX 请问 Nginx 怎么添加 CORS 白名单? - V2EX 使用 nginx 监听已被监听的端口, reload 不会失败, 但会导致其他配置不生效. - V2EX nginx 如何获取/打印完整代理路径? - V2EX Nginx 四层反代 QUIC 如何传递客户端 IP - V2EX 关于 windows 下面重启之后 nginx 的问题 - V2EX 我是不是可以反向代理个 V2EX 网站? - V2EX 用 nginx 做的 xai 的转发好像一直有问题 - V2EX 请教一个 Nginx 配置和浏览器强制 http 转 https 问题 - V2EX nginx proxy manager ipv6 反代指向内网 ipv4 局域网地址,还可以这样操作🤔? - V2EX 关于 Nginx 反向代理性能调优的问题,求指导🙏 - V2EX nginx 配置根据请求头分发问题 - V2EX 用过 nginx-proxy-manager 请进, 咨询个问题. - V2EX 我有一个端口转发问题,求大佬们协助 - V2EX 使用 Nginx 代理 Emby 服务器,浏览器可以访问但是客户端连不上 - V2EX 小白在使用 Nginx proxy manager 遇到问题,请大佬们指教。 - V2EX 请教下 nginx 反代配置 - V2EX nginx 配置问题求解答 - V2EX Nginx 流量异常,请大佬支招~ - V2EX nginx 读取 ssl 证书的权限问题请教 - V2EX 请问一个二级域名如何配置可以访问多个 http 服务? - V2EX 配置证书相关的问题 - V2EX 关于 nginx 的一些提问 - V2EX nginx 限流失败的奇怪问题 - V2EX 反向代理提示该网站已被拦截,请教 - V2EX 为什么我的 docker nginx 的不能反向代理 favicon 啊 - V2EX Nginx 能不能实现按域名限制网速? - V2EX 请教一下各位关于 nginx 版本更新区别导致反向代理无法访问的问题 - V2EX 虚心请教一个有关于 nginx 配置的问题 - V2EX 求解 nginx 反代某堡垒机 443 页面出现问题 - V2EX nginx if 语句 return 403,没办法跳转自定义 403 页面 - V2EX 请教 nginx deny 优先级的问题。 - V2EX 求教关于反代的问题 - V2EX nginx 增加 http 块 就报证书错误,请问是什么原因,第一次见 - V2EX 有台生产服务器, Nginx 每天都会因为不同原因 exit 一次,虽然配了自动重启,有没办法排查是什么原因?平均一天 1820 万请求 - V2EX openresty 怎么修改代理站的文件返回给客户端 有啥平替 resend、ZeptoMail 的国内解决方案嘛? 求救:屏蔽爬虫试了 2 天,没成功 - V2EX
nginx rewrite 指令的问题 - V2EX
kyonn · 2025-08-02 · via NGINX

手头没有现成的测试环境,AI 的回答感觉也不太靠谱,咨询下 V 友 关于 nginx rewrite 指令的问题:

一、rewrite 指令的正则表达式是部分匹配还是完全匹配才生效?

比如下面的配置中,请求 /name/jane-lotus 肯定会触发 rewrite 指令,最终请求地址为 http://user-center/users?name=jane-lotus 。

那么请求 /name/regions/bbb 会不会触发 rewrite 的 URI 替换?最终请求地址是多少?

这篇文章说不会触发 rewrite ,AI 的回答是会触发 rewrite 。

location /name/ {
    rewrite /name/([^/]+) /users?name=$1 break;
    proxy_passs http://user-center/main/basicinfo/;
}

二、还是上面的配置,假如原始请求里带了查询参数,那么触发 rewrite 后会不会把原始请求参数也追加给新的请求地址? rewrite 新目标里有没有新的查询参数是否会影响老的查询参数追加到最终请求里?

三、是否有比较系统的 nginx 配置教程推荐或者模拟测试环境验证 nginx 详细执行过程的方法?

第 1 条附言  ·  2025 年 8 月 3 日

实测 rewrite 不需要完全匹配,只要部分匹配了就会进行替换,且没匹配的部分直接被丢弃。另外,原始请求的查询参数会被直接追加到新请求上,除非 rewrite 的新字符串末尾增加?符号。

测试代码如下:
docker exec -it nginx nginx -s reload && curl http://127.0.0.1/name/ggg/ccc?bb=cc

```
worker_processes 1;
worker_rlimit_nofile 8192;

events {
worker_connections 4096;
}

http {
include /etc/nginx/mime.types;
index index.html index.htm index.php;

server {
listen 80;
server_name basic;
access_log /dev/stdout;

location / {
proxy_pass http://httpbin.org;
}
location /deny {
deny all;
}
location /name/ {
rewrite /name/([^/]+) /users?name=$1 break;
proxy_pass http://127.0.0.1:5448;
}
}

server {
listen 5448;
server_name basic;
access_log /dev/stdout;

location / {
add_header Content-Type text/plain;
return 200 "$request_uri";
}
location /deny {
deny all;
}
}

}
```