[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=/$ ...
随机推荐
- python基本数据类型——元组
元组 元组是一种不可变的序列,创建后不可以修改元素值 # 创建只包含一个元素的元组 >>a = (3,) >>print(a) (3,) #使用 tuple() 转换为元组 & ...
- Ubuntu 16.04 安装显卡驱动后循环登录和无法设置分辨率的一种解决方案
1. 安装环境 电脑:MSI GP63 显卡:GeForce GTX 1070 系统:Ubuntu 16.04 驱动版本:NVIDIA 384.130 2. 循环登录 如果按照这篇文章 Ubuntu ...
- mysql 导入 大sql文件
任务:第一次用mysql,需要将一个1G左右的sql文件导入: 步骤:1:安装mysql-installer-community-5.7.20.0.msi 64位安装包 2:命令行登录: mysql ...
- java---Map接口实现类
Map是一个双列集合接口,如果实现了Map接口,特点是数据以键值对形式存在,键不可重复,值可以重复.java中主要有HashMap.TreeMap.Hashtable.本文主要介绍Map的接口方法: ...
- (十一)instanceof 和 getclass 的区别
判断两个对象是否为同一类型,时常用到getclass 和 instanceof ,而这两个函数又是时常让人混淆.下面从一个例子说明两者的区别: public class Test_drive { pu ...
- Launch Image消失时添加动画
CGSize viewSize = self.window.bounds.size; NSString *viewOrientation = @"Portrait"; //横屏请设 ...
- jsp连接MYSQL数据库教程(文字+图)
步骤: 1.在mysql官网下载JDBC驱动程序.网址:https://dev.mysql.com/downloads/connector/j/ 2.把里面的jar包(mysql-connector- ...
- SQL Server之看懂执行计划
在SQL Server中,选中一段SQL按Ctrl+L,就可以查看它的执行计划. 上面是一个执行计划的实例,在SQL Server中,执行计划是从右往左看的. SQL Server中,查找数据的方式有 ...
- 3dContactPointAnnotationTool开发日志(二一)
今天完成了修改按钮颜色,添加smpl模型到工具,以及可以显示物体子物体对应选项卡的功能.把之前的meshRenderer+meshFilter都改成了skinnedMeshRenderer,因为s ...
- 软工网络15团队作业4——Alpha阶段敏捷冲刺-3
一.当天站立式会议照片: 二.项目进展 昨天已完成的工作: 依靠HTML 逻辑框架等技术完成程序界面前端的实现. 明天计划完成的工作: 依靠css 逻辑框架等技术完成程序界面前端的实现. 工作中遇到的 ...