While passing request nginx replaces URI part which corresponds to location with one indicated in proxy_pass directive. But there are two exceptions from this rule when it is not possible to determine what to replace:

if the location is given by regular expression;
if inside proxied location URI is changed by rewrite directive, and this configuration will be used to process request (break):
location /name/ {
rewrite /name/([^/] +) /users?name=$ break;
proxy_pass http://127.0.0.1;
}
For these cases of URI it is transferred without the mapping.
注意:
两种情况下不进行代理转换。
1.location 标段使用正则表达式
2.执行代理动作的location段内使用了rewrite指令对location URI进行了修改,并且使用rewrite后的配置发出请求(break)。

A special case is using variables in the proxy_pass statement: The requested URL is not used and you are fully responsible to construct the target URL yourself.

This means, the following is not what you want for rewriting into a zope virtual host monster, as it will proxy always to the same URL (within one server specification):

另一种特例是在proxy_pass语句中使用变量:请求的url并没有被使用,你必须自己构造目标url

location / {
proxy_pass http://127.0.0.1:8080/VirtualHostBase/https/$server_name:443/some/path/VirtualHostRoot;
}
Instead use a combination of rewrite and proxy_pass:上面的语句要写成下面的: location / {
rewrite ^(.*)$ /VirtualHostBase/https/$server_name:/some/path/VirtualHostRoot$ break;
proxy_pass http://127.0.0.1:8080;
}
rewrite的permanent和redirect重写后的url会在url栏显示,在数据包的层面,添加了location http header
这块东西还是有不少不清楚的地方,继续研究。

[nginx]proxy_pass&rewrite知识点的更多相关文章

  1. nginx几个知识点汇总

    WHY? 为什么用Nginx而不用LVS? 7点理由足以说明一切:1 .高并发连接: 官方测试能够支撑 5 万并发连接,在实际生产环境中跑到 2 - 3 万并发连接数.?2 .内存消耗少: 在 3 万 ...

  2. 使用nginx的rewrite实现代理指定文件夹命令方法

    使用nginx的rewrite实现代理指定文件夹命令方法 使用nginx代理Tomcat,Tomcat公布web的时候通常都是带着项目名称的. 比方项目名称为"aven".那么公布 ...

  3. Nginx的Rewrite规则与实例

    通过Rewrite规则可以实现规范的URL.根据变量来做URL转向及选择配置,用好Rewrite有时起到事半功倍的效果. 语法 Nginx的Rewrite相比Apache的要好理解很多,主要使用指令有 ...

  4. Nginx的rewrite应用

    Rewrite主要的功能是实现URL重写,Nginx 的 Rewrite 规则采用 PCRE Perl 兼容正则表达式的语法进行规则匹配,如相使用 Nginx 的 Rewrite 功能,在编译 Ngi ...

  5. Nginx使用rewrite重新定向

    [Rewrite重定向]Nginx使用rewrite重新定向   使用nginx做重新定向. nginx参考网址:http://blog.sina.com.cn/s/blog_97688f8e0100 ...

  6. nginx 配置rewrite 笔记

    nginx 配置rewrite笔记: 通过下面的示例来说明一下,1. 先说说location : location 表示匹配传入的url地址,其中配置符有多种,各种情况的意义不一样: location ...

  7. Nginx重定向[Rewrite]配置 for wordpress & Discuz

    首先Apache的Rewite规则差别不是很大,但是Nginx的Rewrite规则比Apache的简单灵活多了Nginx可以用if进行条件匹配,语法规则类似Cif ($http_user_agent ...

  8. nginx 带? rewrite 规则

    由于需要重定向 url ,nginx需要rewrite .参考文献 http://huangqiqing123.iteye.com/blog/2083434 需求:将http://10.106.1.3 ...

  9. php ci nginx 伪静态rewrite配置方法

    php ci nginx 伪静态rewrite配置方法 location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$ ...

随机推荐

  1. Java并发基础--Lock的学习

    一.Lock的出现 Lock的主要作用实现线程之间的同步互斥,与synchronized关键字的效果是一样的,synchronized是Java语言内置的特性,那么为什么又出现了Lock呢?原因是sy ...

  2. gitolite 丢失管理密钥/访问权限 解决办法

    登录到服务器. 使用完整路径克隆管理员仓库: git clone $HOME/repositories/gitolite-admin.git temp cd gitolite-admin/conf v ...

  3. [转载]CENTOS 6.0 iptables 开放端口80 3306 22端口

    原文地址:6.0 iptables 开放端口80 3306 22端口">CENTOS 6.0 iptables 开放端口80 3306 22端口作者:云淡风轻 #/sbin/iptab ...

  4. leetcode个人题解——#20 Valid Parentheses

    class Solution { public: bool isValid(string s) { stack<char> brackts; ; i < s.size(); i++) ...

  5. 2018Java研发实习内推

    作者:sdu王镜鑫链接:https://www.nowcoder.com/discuss/74573?type=0&order=4&pos=7&page=1来源:牛客网 本人某 ...

  6. Daily Scrum 10

    今天我们小组开会内容分为以下部分: part 1: 经过反复思考,对于上次组会确定的在系统中加入娱乐版块进行了更进一步的商讨; part 2:继续探讨算法实现: part 3:进行明日的任务分配; ◆ ...

  7. SOA是什么为什么要面向服务编程

    SOA(面向服务的架构),Service-Oriented Architecture,面向服务的体系结构. 也就是以服务为核心的架构.这里需要理解什么是服务. 比如你有一个读取通知的方法: publi ...

  8. LintCode-50.数组剔除元素后的乘积

    数组剔除元素后的乘积 给定一个整数数组A. 定义B[i] = A[0] * ... * A[i-1] * A[i+1] * ... * A[n-1], 计算B的时候请不要使用除法. 样例 给出A=[1 ...

  9. iOS-开发将文本复制到剪切板

    下面方法可以将文本复制到剪切板 UIPasteboard *pboard = [UIPasteboard generalPasteboard]; pboard.string = @"邀请码& ...

  10. alpha阶段个人总结(201521123034陈凯欣)

    一.个人总结 第 0 部分:基本数据结构和算法问题 大二的时候上过数据结构课,感觉自己没有学的太深入,就如之前结对编程时候四则运算有用到的二叉树来解决问题,对于二叉树就有个模糊的概念,实际动手操作起来 ...