使用Nginx搭建小偷站點(diǎn)(鏡像站點(diǎn))

前文

Nginx 本身是可以替換反向代理的內(nèi)容的
使用的是 sub_filter 這個(gè)函數(shù). 但是他不能替換多個(gè)相同的內(nèi)容. 這不能滿足我們的要求
substitutions 這是一個(gè)Nginx 的第三方Model, 他可以提供加強(qiáng)版的sub_filter, 使用的函數(shù)是subs_filter, 可以支持正則匹配. 批量替換

安裝我的Nginx軟件包

鏈接:https://pan.baidu.com/s/1NmFd4EAgpR6D0xj3vcKE3g 密碼:a834

注意!!! 把里面的內(nèi)容解壓到root 目錄. 因?yàn)槲业陌惭b腳本地址是寫死的

文件內(nèi)容

-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    //一個(gè)友好的網(wǎng)站
-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

解壓完成后. 文件夾應(yīng)該是這樣的

[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

安裝完畢后來寫一個(gè)簡(jiǎn)單的Demo來試試

此時(shí)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';
    }
}

效果出來啦 我把百度的圖標(biāo)緩存了搜狗的

QQ20160307-0.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 第一章 Nginx簡(jiǎn)介 Nginx是什么 沒有聽過Nginx?那么一定聽過它的“同行”Apache吧!Ngi...
    JokerW閱讀 33,011評(píng)論 24 1,002
  • 編譯自:installing-nginx-open-source 目錄 選擇 Stable 還是 Mainline...
    C86guli閱讀 3,937評(píng)論 0 21
  • 一、MemCache簡(jiǎn)介 session MemCache是一個(gè)自由、源碼開放、高性能、分布式的分布式內(nèi)存對(duì)象緩存...
    李偉銘MIng閱讀 3,993評(píng)論 2 13
  • 江南 靜靜的思念 沒有盡期 一首寫不完的詩 想你我就寫你 看不完這江南 終究少一個(gè)你 落下的春雨 滴在檐間 落在人...
    自此流離閱讀 226評(píng)論 1 2
  • 多年后,再回想年少時(shí)的迷茫和執(zhí)著,或許原因都記不得了。青春就是讓你張揚(yáng)的笑,也給你莫名的痛
    遺忘的街角閱讀 246評(píng)論 0 0

友情鏈接更多精彩內(nèi)容