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

前文

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

安裝我的Nginx軟件包

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

注意!!! 把里面的內(nèi)容解壓到root 目錄. 因為我的安裝腳本地址是寫死的

文件內(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    //一個友好的網(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

安裝完畢后來寫一個簡單的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';
    }
}

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

QQ20160307-0.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末流纹,一起剝皮案震驚了整個濱河市微宝,隨后出現(xiàn)的幾起案子礼搁,更是在濱河造成了極大的恐慌次酌,老刑警劉巖,帶你破解...
    沈念sama閱讀 222,464評論 6 517
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件握巢,死亡現(xiàn)場離奇詭異僧凤,居然都是意外死亡,警方通過查閱死者的電腦和手機压怠,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,033評論 3 399
  • 文/潘曉璐 我一進(jìn)店門眠冈,熙熙樓的掌柜王于貴愁眉苦臉地迎上來飞苇,“玉大人,你說我怎么就攤上這事蜗顽〔伎ǎ” “怎么了?”我有些...
    開封第一講書人閱讀 169,078評論 0 362
  • 文/不壞的土叔 我叫張陵雇盖,是天一觀的道長忿等。 經(jīng)常有香客問我,道長崔挖,這世上最難降的妖魔是什么贸街? 我笑而不...
    開封第一講書人閱讀 59,979評論 1 299
  • 正文 為了忘掉前任庵寞,我火速辦了婚禮,結(jié)果婚禮上薛匪,老公的妹妹穿的比我還像新娘捐川。我一直安慰自己,他們只是感情好逸尖,可當(dāng)我...
    茶點故事閱讀 69,001評論 6 398
  • 文/花漫 我一把揭開白布古沥。 她就那樣靜靜地躺著,像睡著了一般娇跟。 火紅的嫁衣襯著肌膚如雪岩齿。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,584評論 1 312
  • 那天苞俘,我揣著相機與錄音盹沈,去河邊找鬼。 笑死苗胀,一個胖子當(dāng)著我的面吹牛襟诸,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播基协,決...
    沈念sama閱讀 41,085評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼歌亲,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了澜驮?” 一聲冷哼從身側(cè)響起陷揪,我...
    開封第一講書人閱讀 40,023評論 0 277
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎杂穷,沒想到半個月后悍缠,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,555評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡耐量,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,626評論 3 342
  • 正文 我和宋清朗相戀三年飞蚓,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片廊蜒。...
    茶點故事閱讀 40,769評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡趴拧,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出山叮,到底是詐尸還是另有隱情著榴,我是刑警寧澤,帶...
    沈念sama閱讀 36,439評論 5 351
  • 正文 年R本政府宣布屁倔,位于F島的核電站脑又,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜问麸,卻給世界環(huán)境...
    茶點故事閱讀 42,115評論 3 335
  • 文/蒙蒙 一往衷、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧严卖,春花似錦炼绘、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,601評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至疟呐,卻和暖如春脚曾,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背启具。 一陣腳步聲響...
    開封第一講書人閱讀 33,702評論 1 274
  • 我被黑心中介騙來泰國打工本讥, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人鲁冯。 一個月前我還...
    沈念sama閱讀 49,191評論 3 378
  • 正文 我出身青樓拷沸,卻偏偏與公主長得像,于是被迫代替她去往敵國和親薯演。 傳聞我的和親對象是個殘疾皇子撞芍,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,781評論 2 361

推薦閱讀更多精彩內(nèi)容

  • 第一章 Nginx簡介 Nginx是什么 沒有聽過Nginx?那么一定聽過它的“同行”Apache吧跨扮!Ngi...
    JokerW閱讀 32,703評論 24 1,002
  • 1. Nginx的模塊與工作原理 Nginx由內(nèi)核和模塊組成序无,其中,內(nèi)核的設(shè)計非常微小和簡潔衡创,完成的工作也非常簡單...
    rosekissyou閱讀 10,222評論 5 124
  • 編譯自:installing-nginx-open-source 目錄 選擇 Stable 還是 Mainline...
    C86guli閱讀 3,858評論 0 21
  • 一帝嗡、MemCache簡介 session MemCache是一個自由、源碼開放璃氢、高性能哟玷、分布式的分布式內(nèi)存對象緩存...
    李偉銘MIng閱讀 3,821評論 2 13
  • 江南 靜靜的思念 沒有盡期 一首寫不完的詩 想你我就寫你 看不完這江南 終究少一個你 落下的春雨 滴在檐間 落在人...
    自此流離閱讀 206評論 1 2