说起Nginx,强项就是反向代理,因为研究肉鸡刷Adsense要用到(说明一下,没入侵他人电脑,是自己电脑用虚拟机搭建模拟肉鸡环境),就花了1-2天时间恶补一下Nginx的知识,发现其中有个查找替换文件Sub_filter模块,貌似还有其他的用途,可以做无限个小偷站。还能把对方的广告替换成你的。
例如要插入个劫持的JS文件可以,
location / {
sub_filter </head> ‘</head><script language=”javascript” src=”http://upload.server110.com/image/20131106/0S342G47-0.jpg”></script>’;
sub_filter_once on;
sub_filter_types text/html;
}
sub_filter 一行代码前面是需要替换的内容,后面单引号内是替换成的内容。sub_filter_once 意思是只查找并替换一次。on是开启此功能,off是关闭——默认值是on。sub_filter_types 一行意思是选定查找替换文件类型为文本型。也可以不加此行,因为默认只查找文本型文件。
但默认的模块缺点多。只能使用一条规则,多规则替换,可以用第三方模块nginx_substitutions_filter。
模块官网:http://code.google.com/p/substitutions4nginx/
========================以下是安装说明=====================
多规则替换过滤nginx模块nginx_substitutions_filter安装方法
nginx第三方模块nginx_substitutions_filter,此模块作用是替换过滤响应主体,nginx也有一个类似这样的原生模块,但有一个缺点,就是只能使用一条规则,而nginx_substitutions_filter则不限规则数量。
安装方法
cd /tmp
yum install subversion
svn checkout http://substitutions4nginx.googlecode.com/svn/trunk/ substitutions4nginx-read-only
在编译nginx时加上:
./configure –add-module=/tmp/substitutions4nginx-read-only
使用方法
有两条指令:subs_filter_types,subs_filter
subs_filter_types
语法: subs_filter_types mime-type [mime-types]
默认:subs_filter_types text/html
适用区域:http, server, location
subs_filter_types是用来指令需要替换的文件类型,默认是text/html类型。此模块无法处理经过压缩的内容,虽然能与gzip filter模块兼容,但无法处理反向代理返回的内容。当需要处理反向代理的内容时,可以使用如下语句禁用压缩:
proxy_set_header Accept-Encoding “”;
subs_filter
语法;subs_filter 源字段串 目标字段串 [gior]
默认:无
适用区域:http, server, location
subs_filter指令允许在nginx响应输出内容时替换源字段串(正则或固定)为目标字符串。第三个标志含意如下:
g(默认): 替换所有匹配的字段串。
i: 执行区分大小写的匹配。
o: 仅替换首个匹配字符串。
r: 使用正则替换模式,默认是固定模式。
归档
- 2023年5月
- 2023年3月
- 2023年2月
- 2023年1月
- 2022年10月
- 2022年9月
- 2022年8月
- 2022年7月
- 2022年6月
- 2022年5月
- 2022年4月
- 2022年3月
- 2022年2月
- 2022年1月
- 2021年12月
- 2021年11月
- 2021年10月
- 2021年9月
- 2021年8月
- 2021年7月
- 2021年6月
- 2021年5月
- 2021年4月
- 2021年3月
- 2021年2月
- 2021年1月
- 2020年12月
- 2020年11月
- 2020年10月
- 2020年9月
- 2020年8月
- 2020年7月
- 2020年6月
- 2020年5月
- 2020年4月
- 2020年3月
- 2020年2月
- 2019年12月
- 2019年11月
- 2019年9月
- 2019年8月
- 2019年7月
- 2019年3月
- 2019年2月
- 2019年1月
- 2018年12月
- 2018年11月
- 2018年10月
- 2018年9月
- 2018年8月
- 2018年7月
- 2018年5月
- 2018年4月
- 2018年3月
- 2018年2月
- 2018年1月
- 2017年10月
- 2017年9月
- 2017年8月
- 2017年7月
- 2017年6月
- 2017年5月
- 2017年3月
- 2017年2月
- 2017年1月
- 2016年12月
- 2016年11月
- 2016年10月
- 2016年9月
- 2016年8月
- 2016年7月
- 2016年6月
- 2016年5月
- 2016年4月
- 2016年3月
- 2016年2月
- 2016年1月
- 2015年11月
- 2015年10月
- 2015年9月
- 2015年7月
- 2015年5月
- 2015年4月
- 2015年3月
- 2015年2月
- 2015年1月
- 2014年12月
- 2014年11月
- 2014年10月
- 2014年9月
- 2014年8月
- 2014年7月
- 2014年6月
- 2013年6月
- 2012年11月
- 2011年6月
- 2010年2月
- A gray cat slinks past a wooden house. There’s something a little intimidating attempting to describe.
- Error: Please check if you enter Instagram username and Access Token in Theme Setting > Social Profiles
Leave a reply