全球主机交流论坛

标题: Nginx 反向代理 做其他网站的镜像 [打印本页]

作者: Router    时间: 2011-11-14 16:03
标题: Nginx 反向代理 做其他网站的镜像
要点只有2个:

1. 反向代理
2. 关键词替换

下面就讲讲过程 (centos5/6-32bit/64bit已测试)

1. nginx + substitutions 安装
nginx 自带一个Substitution模块,
但该模块只能写一行,所以我们改用 substitutions

下面是安装一些预备软件

yum -y –noplugins install wget zip
yum -y –noplugins install unzip
yum -y –noplugins install gcc
yum -y –noplugins install make
yum -y –noplugins install pcre-devel
yum -y –noplugins install openssl-devel

下载软件

wget -c http://www.nginx.org/download/nginx-1.0.8.tar.gz                      //下载nginx
svn checkout http://substitutions4nginx.googlecode.com/svn/trunk/ substitutions4nginx-read-only          //下载substitutions

编译软件
tar zxf nginx-1.0.8.tar.gz
cd nginx-1.0.8.tar.gz
./configure ./configure –add-module=path/substitutions4nginx-read-only           //注意这里的path是相对应的真实路径

make
make install

此时,nginx应该安装在于 /usr/local/nginx 下面
配置 nginx.conf
server_name  www.你的域名.com;
location / {
subs_filter 1原内容  2新内容;
subs_filter 源内容   新内容;
proxy_pass   http://www.别人域名.com;
index  index.html index.php index.htm;
}
记住subs_filter 命令的格式,你想替换设么就随你了。
比如我把网站的网址www.1.com替换成了www.2.com

这种模式最好是修改nginx源代码 把301 move的head改为200 ok的返回
否则Google可能有关键词权重的问题….
还有就是正则表达式的写法 处理掉get和post的相关请求后缀

http://blog.cnlabs.net/?p=2444
作者: Kvm    时间: 2011-11-14 16:04


http://www.kvm.la/2011/09/26/33.html


坑爹
作者: 大胡子    时间: 2011-11-14 16:05
技术贴 出售此楼
作者: 大胡子    时间: 2011-11-14 16:06
标题: 回复 2# Kvm 的帖子
好妹妹  睡午觉醒了

作者: 韦小宝    时间: 2011-11-14 16:06
收藏了感谢
作者: edmin    时间: 2011-11-14 16:06
好像在KVMLA那看过
作者: Kvm    时间: 2011-11-14 16:06
nginx.conf的内容贴不出来了吧
作者: Router    时间: 2011-11-14 16:15
标题: 回复 7# Kvm 的帖子
我是转载的,你去原创链接质问吧
作者: wins    时间: 2011-11-14 16:22
提示: 作者被禁止或删除 内容自动屏蔽
作者: wusir    时间: 2011-11-14 16:24
后面修改nginx源代码没详细呀
作者: ls2829373    时间: 2011-11-14 16:26
mark一下。




欢迎光临 全球主机交流论坛 (https://91ai.net/) Powered by Discuz! X3.4