[nginx]proxy_pass&rewrite知识点
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;
}
[nginx]proxy_pass&rewrite知识点的更多相关文章
- nginx几个知识点汇总
WHY? 为什么用Nginx而不用LVS? 7点理由足以说明一切:1 .高并发连接: 官方测试能够支撑 5 万并发连接,在实际生产环境中跑到 2 - 3 万并发连接数.?2 .内存消耗少: 在 3 万 ...
- 使用nginx的rewrite实现代理指定文件夹命令方法
使用nginx的rewrite实现代理指定文件夹命令方法 使用nginx代理Tomcat,Tomcat公布web的时候通常都是带着项目名称的. 比方项目名称为"aven".那么公布 ...
- Nginx的Rewrite规则与实例
通过Rewrite规则可以实现规范的URL.根据变量来做URL转向及选择配置,用好Rewrite有时起到事半功倍的效果. 语法 Nginx的Rewrite相比Apache的要好理解很多,主要使用指令有 ...
- Nginx的rewrite应用
Rewrite主要的功能是实现URL重写,Nginx 的 Rewrite 规则采用 PCRE Perl 兼容正则表达式的语法进行规则匹配,如相使用 Nginx 的 Rewrite 功能,在编译 Ngi ...
- Nginx使用rewrite重新定向
[Rewrite重定向]Nginx使用rewrite重新定向 使用nginx做重新定向. nginx参考网址:http://blog.sina.com.cn/s/blog_97688f8e0100 ...
- nginx 配置rewrite 笔记
nginx 配置rewrite笔记: 通过下面的示例来说明一下,1. 先说说location : location 表示匹配传入的url地址,其中配置符有多种,各种情况的意义不一样: location ...
- Nginx重定向[Rewrite]配置 for wordpress & Discuz
首先Apache的Rewite规则差别不是很大,但是Nginx的Rewrite规则比Apache的简单灵活多了Nginx可以用if进行条件匹配,语法规则类似Cif ($http_user_agent ...
- nginx 带? rewrite 规则
由于需要重定向 url ,nginx需要rewrite .参考文献 http://huangqiqing123.iteye.com/blog/2083434 需求:将http://10.106.1.3 ...
- php ci nginx 伪静态rewrite配置方法
php ci nginx 伪静态rewrite配置方法 location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$ ...
随机推荐
- 剑指offer-栈的压入弹出序列21
题目描述 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否可能为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压 ...
- TensorFlow入门之MNIST最佳实践-深度学习
在上一篇<TensorFlow入门之MNIST样例代码分析>中,我们讲解了如果来用一个三层全连接网络实现手写数字识别.但是在实际运用中我们需要更有效率,更加灵活的代码.在TensorFlo ...
- 1.安装hbase
参考:http://hbase.apache.org/book.html#quickstart 一.下载hbase 去apache下载hbase,然后解压到/usr/local/hbase-1.1.3 ...
- Centos6配置开启FTP Server
vsftpd作为FTP服务器,在Linux系统中是非常常用的.下面我们介绍如何在centos系统上安装vsftp. 什么是vsftpd vsftpd是一款在Linux发行版中最受推崇的FTP服务器程序 ...
- Linux 静态和动态添加路由
(一)静态添加 1/5 首先让我们查看当前机器的路由表,执行如下命令:route -n [root@vnode33 network-scripts]# route -n Kernel IP routi ...
- js经典试题之ES6
js经典试题之ES6 1:在ECMAScript6 中,Promise的状态 答案:pending resolved(fulfilled) rejected 解析: Promise对象只有三种状态: ...
- C语言--链表基础模板
1.建立结构体 struct ST { int num;///学号 int score;///成绩 struct ST*next; };///结构体 2.空链表的创建 struct ST creatN ...
- Alpha阶段中间产物
空天猎功能说明书:https://git.coding.net/liusx0303/Plane.git 空天猎代码控制:https://coding.net/u/MR__Chen/p/SkyHunte ...
- activiti工作流已办和待办查询sql
最近项目中遇到一个问题,需要activiti的工作流表和业务表关联分页查询,然而我对于工作流的查询并不太熟悉,所以学习并总结如下. 想看看activiti到底怎么查询的待认领和待办.已办的查询sql, ...
- c# 中base64字符串和图片的相互转换
c#base64字符串转图片用到了bitmap类,封装 GDI+ 位图,此位图由图形图像及其特性的像素数据组成. Bitmap 是用于处理由像素数据定义的图像的对象. 具体bitmap类是什么可以自己 ...