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 ...
随机推荐
- priority_queue的运算符重载问题
对于需要比较的函数或STL(最常见的为sort,priority_queue) 要对自创的结构进行运算符重载(sort可以写cmp,一样的效果) 1.只能对小于号重载 cmp函数与其起到相同的作用 2 ...
- [luogu3455]ZAP-Queries
有时候我们会遇到一类问题:求$f(n)$,当然它是不好直接计算的,但如果$F(n)=\sum\limits_{d|n}f(d)$或$F(n)=\sum\limits_{\substack{n|d\\d ...
- NSNotificationCenter监听TextField文字变化
注册 1: NSNotificationCenter.defaultCenter().addObserver(self, selector: "textDidChange", na ...
- linux-统计文件中相同行的数量
cat sorttest | sort | uniq -c sorttest文件内容如下
- 重大新闻:腾讯大杀器来了,QQ浏览器微信版推出
今日,腾讯在推出windows桌面版的微信后,又发布了一个重量级产品:QQ浏览器微信版 我们在PC端用微信又多了一种方式,而且比windows桌面版本更加友好,更加方便. 我相信:对于我们绝大多数办公 ...
- [WPF]绑定到界面的数组不支持调度线程以外对其更改的办法
[原]WPF编程经常遇到一个问题: 某个数组己绑定到主界面某控件中,然后在后台程序中需要对数组增(减)数据,然后程序就会报错, 程序提示:该类型的CollectionView 不支持从调度程序线程以外 ...
- QEMU, a Fast and Portable Dynamic Translator
AbstractWe present the internals of QEMU, a fast machine emulator using an original portable dynamic ...
- HTML5 Canvas 笛卡尔坐标系转换尝试
<!DOCTYPE html> <html lang="utf-8"> <meta http-equiv="Content-Type&quo ...
- java 压缩和解压zip包
网上有关压缩和解压zip包的博文一大堆,我随便找了一个.看了看,依照自己的须要改动了一下,与各位分享一下,希望各位大神指正: package com.wangpeng.utill; import ja ...
- ThreadLocal的实现原理(读书笔记)
ThreadLocal的set方法和get方法,从set方法开始: public void set(T value) { Thread t = Thread.currentThread();//获取当 ...