Skip to content

Instantly share code, notes, and snippets.

@latpaw
Last active August 29, 2015 13:56
Show Gist options
  • Save latpaw/9264141 to your computer and use it in GitHub Desktop.
Save latpaw/9264141 to your computer and use it in GitHub Desktop.
已经编译安装过的nginx添加过滤关键字的module
#!/bin/bash
set -e
git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module.git ./filter
if [[ -s nginx-1.2.7.tar.gz ]]; then
echo nginx exists, ready to extract;
else
echo Nothing found, downloading ...
wget -c http://soft.vpser.net/web/nginx/nginx-1.2.7.tar.gz
fi
tar -zxvf nginx-1.2.7.tar.gz
cd nginx-1.2.7
current=`nginx -V 2>&1 | tail -1 | cut -b 22-`
./configure $current --add-module=/root/filter
make
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
nginx -s stop
cp -f ./objs/nginx /usr/local/nginx/sbin/nginx
nginx
wget http://www.example.com/subs_filter.conf
cp subs_filter.conf /usr/local/nginx/conf/subs_filter.conf
echo "Just include the conf file into the nginx.conf "
subs_filter (keyword|keyword2|(keyw\d\s)) '' ir;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment