使用Nginx搭建小偷站点(镜像站点)

前文

Nginx 本身是可以替换反向代理的内容的
使用的是 sub_filter 这个函数. 但是他不能替换多个相同的内容. 这不能满足我们的要求
substitutions 这是一个Nginx 的第三方Model, 他可以提供加强版的sub_filter, 使用的函数是subs_filter, 可以支持正则匹配. 批量替换

安装我的Nginx软件包

链接:https://pan.baidu.com/s/1NmFd4EAgpR6D0xj3vcKE3g 密码:a834

注意!!! 把里面的内容解压到root 目录. 因为我的安装脚本地址是写死的

文件内容

-rw-r--r-- 1 root root  817599 Mar  6 22:06 nginx-1.7.5.tar.gz   //Nginx 安装包
-rw-r--r-- 1 root root 5262089 Mar  6 22:06 openssl-1.0.2a.tar.gz    //Nginx SSL 依赖
-rw-r--r-- 1 root root 2041593 Mar  6 22:06 pcre-8.37.tar.gz          //Nginx 依赖
-rw-r--r-- 1 root root     280 Mar  6 22:06 subs_filter.filter            // 替换demo
-rw-r--r-- 1 root root  112850 Mar  6 22:06 substitutions4nginx-read-only.zip  //subs_filter 插件
-rw-r--r-- 1 root root     287 Mar  6 22:06 t66y.conf    //一个友好的网站
-rw-r--r-- 1 root root    1596 Mar  6 22:06 youtube.conf   //YouTube的代理. 但是没能解决被墙问题
-rw-r--r-- 1 root root  548499 Mar  6 22:06 zlib-1.2.5.1.tar.gz   //Nginx 依赖
 tar -zxvf nginx-1.7.5.tar.gz
 tar -zxvf pcre-8.37.tar.gz 
 tar -zxvf openssl-1.0.2a.tar.gz 
 tar -zxvf zlib-1.2.5.1.tar.gz
 unzip substitutions4nginx-read-only.zip

解压完成后. 文件夹应该是这样的

[root@3xhub0fo4m nginx]# pwd
/root/nginx
[root@3xhub0fo4m nginx]# ll
total 8616
drwxr-xr-x  9 1001  1001    4096 Mar  6 22:15 nginx-1.7.5
-rw-r--r--  1 root root   817599 Mar  6 22:06 nginx-1.7.5.tar.gz
drwxr-xr-x 22 root root     4096 Mar  6 22:17 openssl-1.0.2a
-rw-r--r--  1 root root  5262089 Mar  6 22:06 openssl-1.0.2a.tar.gz
drwxr-xr-x  7 1169  1169    4096 Apr 28  2015 pcre-8.37
-rw-r--r--  1 root root  2041593 Mar  6 22:06 pcre-8.37.tar.gz
-rw-r--r--  1 root root      280 Mar  6 22:06 subs_filter.filter
drwxr-xr-x  5 root root     4096 May 30  2015 substitutions4nginx-read-only
-rw-r--r--  1 root root   112850 Mar  6 22:06 substitutions4nginx-read-only.zip
-rw-r--r--  1 root root      287 Mar  6 22:06 t66y.conf
-rw-r--r--  1 root root     1596 Mar  6 22:06 youtube.conf
drwxr-xr-x 13  501 games    4096 Sep 10  2011 zlib-1.2.5.1
-rw-r--r--  1 root root   548499 Mar  6 22:06 zlib-1.2.5.1.tar.gz

安装必要的组件

yum -y install openssl-devel pcre-devel make gcc gcc-c++ unzip wget zip subversion 

32 Centos 编译命令

./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables' --add-module=/root/nginx/substitutions4nginx-read-only --with-pcre=/root/nginx/pcre-8.37 --with-openssl=/root/nginx/openssl-1.0.2a --with-zlib=/root/nginx/zlib-1.2.5.1

64 Centos 编译命令

./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --add-module=/root/nginx/substitutions4nginx-read-only --with-pcre=/root/nginx/pcre-8.37 --with-openssl=/root/nginx/openssl-1.0.2a --with-zlib=/root/nginx/zlib-1.2.5.1

安装

make
make install

安装完毕后来写一个简单的Demo来试试

此时Nginx 的安装目录在
/etc/nginx

修改nginx.conf
添加如下代码

server {
    listen 80;
    #server_name bd.totzcc.com;
    location / {
        proxy_pass https://www.baidu.com;
        proxy_set_header Accept-Encoding "";
        subs_filter '//www.baidu.com/img/bd_logo1.png' 'https://www.sogou.com/images/logo/new/search400x150.png';
    }
}

效果出来啦 我把百度的图标缓存了搜狗的

使用Nginx搭建小偷站点(镜像站点)_第1张图片
QQ20160307-0.png

你可能感兴趣的:(使用Nginx搭建小偷站点(镜像站点))