proxy_redirect参数的作用
Nginx的代理功能太完善了,我们看看proxy_redirect参数的作用。 案例说明:
要做一个html.aslibra.com的域名处理很多网站的html内容,当然是后端的服务器了,目录分析
html.zcom.com/img.aslibra.com/
html.zcom.com/css.aslibra.com/
访问的域名是该目录下的域名,那前端nginx的配置应该类似这样: server {
server_name img.aslibra.com;
location / {
rewrite ^(.*) /$http_host$ break;
proxy_set_header Host html.aslibra.com;
proxy_pass http://cache-89;
}
} 但这样访问目录时如果没有以“/”结尾,则服务器会返回301redirect: [root@aslibra ~]# curl -I http://img.aslibra.com/www
HTTP/1.1 Moved Permanently
Server: nginx/0.7.
Date: Tue, Jul :: GMT
Connection: keep-alive
Location: http://html.aslibra.com/img.aslibra.com/www/ html.aslibra.com这个域名并非公布的域名,返回给客户端是会自然产生错误的
Nginx可以很好的处理这个问题: server {
server_name img.aslibra.com;
location / {
rewrite ^(.*) /$http_host$ break;
proxy_set_header Host html.aslibra.com;
proxy_pass http://cache-89;
proxy_redirect http://html.aslibra.com/img.aslibra.com/ /;
}
} 加一行proxy_redirect后,正常了: [root@aslibra ~]# curl -I http://img.aslibra.com/www
HTTP/1.1 Moved Permanently
Server: nginx/0.7.
Date: Tue, Jul :: GMT
Content-Type: text/html
Location: http://img.aslibra.com/www/
Connection: keep-alive
Content-Length:
Expires: Tue, Jul :: GMT
Cache-Control: max-age= 就这么样就ok啦~
不过貌似不支持变量出现在地址里,这个就郁闷了,必须指定相应域名。
对于多个域名匹配的server,redirect设置不能写作’/'了,否则会用第一个域名作为redirect域名
可以写几个匹配规则: proxy_redirect http://html.aslibra.com/img.aslibra.com/ http://img.aslibra.com/;
proxy_redirect http://html.aslibra.com/css.aslibra.com/ http://css.aslibra.com/;
proxy_redirect参数的作用的更多相关文章
- jQuery ajax的traditional参数的作用///////////////////////////////////zzzzzzzzzzz
jQuery ajax的traditional参数的作用 i33 发布时间: 2013/04/03 10:05 阅读: 9859 收藏: 9 点赞: 1 评论: 0 一般的,可能有些人在一个参数有多个 ...
- 关于context:component-scan配置中use-default-filters参数的作用
参考了多篇文章都说明了use-default-filters参数的基本用途,但有些主要点没有说到,这里补充记录下: <context:component-scan base-package=&q ...
- Dos del参数与作用(/f/s/q)
Dos del参数与作用(/f/s/q) C:\Documents and Settings>del /? 删除一个或数个文件. DEL [/P] [/F] [/S] [/Q] [/A[[:]a ...
- Jquery中Ajax异步请求中的async参数的作用
之前不知道这个参数的作用,上网找了前辈的博客,在此收录到自己的博客,希望能帮到更多的朋友: test.html <a href="javascript:void(0)" on ...
- pytorch autograd backward函数中 retain_graph参数的作用,简单例子分析,以及create_graph参数的作用
retain_graph参数的作用 官方定义: retain_graph (bool, optional) – If False, the graph used to compute the grad ...
- 神经网络中w,b参数的作用(为何需要偏置b的解释)
http://blog.csdn.net/xwd18280820053/article/details/70681750 可视图讲解神经元w,b参数的作用 在我们接触神经网络过程中,很容易看到就是这样 ...
- mysql中,创建表的时候指定if not exists参数的作用?
需求说明: 在创建表的时候,如果指定if not exists语句,有什么作用,在此做个实验,并且官方手册, 理解下这个参数的作用. 操作过程: 1.创建测试表test01 mysql> cre ...
- mysql的jdbc.url携带allowMultiQueries=true参数的作用及其原理
如下配置 jdbc.url=jdbc:mysql://127.0.0.1:3306/chubb_2?autoReconnect=true&useUnicode=true&charact ...
- backward的gradient参数的作用
backward的gradient参数的作用 待办 https://zhuanlan.zhihu.com/p/29904755 https://zhuanlan.zhihu.com/p/2992309 ...
随机推荐
- [BZOJ1559]密码
数据范围特别小,考虑状压DP 因为要求给定的字符串在母串中出现,所以可以用AC自动机辅助DP 因为AC自动机不能处理模式串互相包含的情况,所以先把互相包含的串去掉(暴力就行,数据范围太小) 因为要状压 ...
- [CF877F]Ann and Books
题目大意: 有$n(n\le10^5)$个数$w_{1\sim n}(|w_i|\le10^9)$,并给定一个数$k(|k|\le10^9)$.$q(q\le10^5)$次询问,每次询问区间$[l,r ...
- FCL研究-集合- System.Collections 接口和对象集合
[目录] 发现自己已经有很长一段时间写代码没什么进步了,随便读读FCL的源码,看看之前一直用的方法是如何实现的,也顺便提高下自己.FCL很是庞大,很难下口,于是用最笨的办法,先看常见的命名空间,逐个展 ...
- 关于char类型的说明
#include<iostream> using namespace std; int main() { char ch=128;//VC编译器默认是有符号的.但c并未明确给出.由编译器 ...
- 利用Java位运算符,完成Unsigned转换(无符号)
方案二:利用Java位运算符,完成Unsigned转换. 正常情况下,Java提供的数据类型是有符号signed类型的,可以通过位运算的方式得到它们相对应的无符号值,参见几个方法中的代码: publi ...
- fidder模拟post提交到PHP遇到的问题
http头必须带上Content-type: application/x-www-form-urlencoded 之后 ,php 才能接收到post数据 1. 用php://input可以很便捷的取 ...
- spring集成redis,集成redis集群
原文:http://chentian114.iteye.com/blog/2292323 1.通过spring-data-redis集成redis pom.xml依赖包 <project xml ...
- 【Git】GitHub for Windows使用(1)
目录 1.下载GitHub for windows 客户端 2.注册GitHub 3.启动windows端客户端,登录帐号 4.了解Git客户端,从而了解Git的大体功能 5.创建一个新的资源库 6 ...
- Swift,循环及判断
1.for循环(执行固定次数的操作) (1)基本数组循环 var a=[1,2,3] for value in a{ print(value) //1 2 3 } (2)自定义循环次数 for i i ...
- Golang优秀开源项目汇总, 10大流行Go语言开源项目, golang 开源项目全集(golang/go/wiki/Projects), GitHub上优秀的Go开源项目
Golang优秀开源项目汇总(持续更新...)我把这个汇总放在github上了, 后面更新也会在github上更新. https://github.com/hackstoic/golang-open- ...