2019-06-012.rewrite應(yīng)用

[root@nginxserver server]#vim www_magedu_net.conf 
  root /data/nginx/html/pc;
if (!-f $request_filename) {
#return 404 "linux36";
rewrite (.*) http://www.magedu.net/index.html;
}
[root@nginxserver server]#nginx-r 

這個(gè)是判斷用戶的請求是否存在,如果不存在就跳轉(zhuǎn)到首頁去
image.png

image.png

通過百度訪問
日志信息記錄通過百度訪問的
訪問這個(gè)網(wǎng)站
[root@nginxserver server]#vim www_mageedu_net.conf 
server {
  listen 80;
  server_name www.mageedu.net;
  access_log /apps/nginx/logs/www_mageedu_net_access.log access_json;
  error_log /apps/nginx/logs/www_mageedu_net_error.log;
  location / {
  root /data/nginx/html/megeedu;
   index index.html;

}
}
}
[root@nginxserver server]#mkdir /data/nginx/html/megeedu
[root@nginxserver server]#cd /data/nginx/html/megeedu


[root@nginxserver megeedu]#vim index.html   寫入一個(gè)倒鏈頁面
server {
  listen 80;
  server_name www.mageedu.net;
  access_log /apps/nginx/logs/www_mageedu_net_access.log access_json;
  error_log /apps/nginx/logs/www_mageedu_net_error.log;
  location / {
  root /data/nginx/html/megeedu;
   index index.html;
}
}
      
添加一個(gè)域名的網(wǎng)站
訪問剛創(chuàng)建的頁面球切,上邊的圖片盜鏈的是magedu的網(wǎng)站谷誓,下邊的圖片盜鏈的是京東的網(wǎng)站
訪問盜鏈的網(wǎng)站
查看日志信息[root@nginxserver ~]#tail -f /apps/nginx/logs/www_magedu_net_*.log 查看哪個(gè)網(wǎng)站在盜鏈
[root@nginxserver server]#vim www_magedu_net.conf 
  ssl_session_timeout 10m;
  location / {
root /data/nginx/html/pc;valid_referers none blocked server_names *.baidu.com  *.example.com example.* www.example.org/galleries/ ~\.google\.;   定義禁止盜鏈的信息
[root@nginxserver server]#nginx-r 

在訪問一次盜鏈的網(wǎng)站就沒有了

攻擊網(wǎng)站
訪問速度變慢了
[root@client ~]#free -m   查看內(nèi)存的信息
              total        used        free      shared  buff/cache   available
Mem:           3773         124        3485          11         162        3428
Swap:          3967           0        3967

[http://tengine.taobao.org/download.html](http://tengine.taobao.org/download.html)
訪問teng.org網(wǎng)站
[root@nginxserver ~]#nginx -s stop  停止這個(gè)服務(wù)
[root@nginxserver src]#cd /usr/local/src/
[root@nginxserver src]#wget http://tengine.taobao.org/download/tengine-2.3.0.tar.gz
[root@nginxserver src]#tar xf tengine-2.3.0.tar.gz   解壓
這個(gè)命令是檢查環(huán)境的  ./configure 

查看安裝的命令
--prefix=/apps/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --add-module=/root/echo-nginx-module
復(fù)制nginx的編譯參數(shù)

[root@nginxserver tengine-2.3.0]#./configure --prefix=/apps/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --add-module=/root/echo-nginx-module
開始編譯tng
[root@nginxserver tengine-2.3.0]#make   安裝
[root@nginxserver tengine-2.3.0]#make clean
rm -rf Makefile objs

[root@nginxserver tengine-2.3.0]#./configure --prefix=/usr/local/tengine --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --add-module=/root/echo-nginx-module
重新編譯安裝,注意目錄
[root@nginxserver tengine-2.3.0]#make
[root@nginxserver tengine-2.3.0]#make install   安裝
[root@nginxserver conf]#vim /usr/local/tengine/conf/nginx.conf
 include /apps/nginx/conf/server/*.conf;  引入之前的nginx的所有配置信息
[root@nginxserver conf]#/usr/local/tengine/sbin/nginx -V   查看tengine版本
Tengine version: Tengine/2.3.0 (nginx/1.15.9)
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/tengine --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --add-module=/root/echo-nginx-module

[root@nginxserver home]#/usr/local/tengine/sbin/nginx -t
nginx: [emerg] unknown log format "access_json" in /apps/nginx/conf/server/www_magedu_net.conf:5  提示日志不支持

nginx: configuration file /usr/local/tengine/conf/nginx.conf test failed
[root@nginxserver home]#vim /usr/local/tengine/conf/nginx.conf
    log_format access_json '{"@timestamp":"$time_iso8601",'
        '"host":"$server_addr",'
        '"clientip":"$remote_addr",'
        '"size":$body_bytes_sent,'
        '"responsetime":$request_time,'
        '"upstreamtime":"$upstream_response_time",'
        '"upstreamhost":"$upstream_addr",'
        '"http_host":"$host",'
        '"uri":"$uri",'
        '"domain":"$host",'
        '"xff":"$http_x_forwarded_for",'
        '"referer":"$http_referer",'
        '"tcp_xff":"$proxy_protocol_addr",'
        '"http_user_agent":"$http_user_agent",'
        '"status":"$status"}';


[root@nginxserver home]#/usr/local/tengine/sbin/nginx -t   在檢查下沒有問題
nginx: the configuration file /usr/local/tengine/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/tengine/conf/nginx.conf test is successful

[root@nginxserver home]#/usr/local/tengine/sbin/nginx  啟動(dòng)服務(wù)
[root@nginxserver home]#echo "alias tnginx='/usr/local/tengine/sbin/nginx'" >>/etc/profile   修改變量
[root@nginxserver home]#source /etc/profile  執(zhí)行腳本
[root@nginxserver home]#tnginx 開啟服務(wù)
訪問網(wǎng)頁tngine
[root@nginxserver conf]#vim /usr/local/tengine/conf/nginx.conf
    server_tokens off;
[root@nginxserver conf]#tnginx -s reload


修改回來的吨凑,這樣就不暴露版本號(hào)了
[root@nginxserver /]#cd /apps/nginx/conf/server/
[root@nginxserver server]#vim www_magedu_net.conf 
     location ^~ /static {
     root /data/nginx/html/pc;
     concat on;
     index index.html;
     }
[root@nginxserver tengine-2.3.0]#./configure --help |grep concat 過濾這個(gè)值  
tng早期的版本支持這個(gè)功能

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末捍歪,一起剝皮案震驚了整個(gè)濱河市户辱,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌糙臼,老刑警劉巖庐镐,帶你破解...
    沈念sama閱讀 219,366評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異变逃,居然都是意外死亡必逆,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,521評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門揽乱,熙熙樓的掌柜王于貴愁眉苦臉地迎上來名眉,“玉大人,你說我怎么就攤上這事凰棉∷鹇#” “怎么了?”我有些...
    開封第一講書人閱讀 165,689評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵撒犀,是天一觀的道長探橱。 經(jīng)常有香客問我,道長绘证,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,925評(píng)論 1 295
  • 正文 為了忘掉前任哗讥,我火速辦了婚禮嚷那,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘杆煞。我一直安慰自己魏宽,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,942評(píng)論 6 392
  • 文/花漫 我一把揭開白布决乎。 她就那樣靜靜地躺著队询,像睡著了一般。 火紅的嫁衣襯著肌膚如雪构诚。 梳的紋絲不亂的頭發(fā)上蚌斩,一...
    開封第一講書人閱讀 51,727評(píng)論 1 305
  • 那天,我揣著相機(jī)與錄音范嘱,去河邊找鬼送膳。 笑死,一個(gè)胖子當(dāng)著我的面吹牛丑蛤,可吹牛的內(nèi)容都是我干的叠聋。 我是一名探鬼主播,決...
    沈念sama閱讀 40,447評(píng)論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼受裹,長吁一口氣:“原來是場噩夢啊……” “哼碌补!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,349評(píng)論 0 276
  • 序言:老撾萬榮一對情侶失蹤厦章,失蹤者是張志新(化名)和其女友劉穎镇匀,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體闷袒,經(jīng)...
    沈念sama閱讀 45,820評(píng)論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡坑律,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,990評(píng)論 3 337
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了囊骤。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片晃择。...
    茶點(diǎn)故事閱讀 40,127評(píng)論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖也物,靈堂內(nèi)的尸體忽然破棺而出宫屠,到底是詐尸還是另有隱情,我是刑警寧澤滑蚯,帶...
    沈念sama閱讀 35,812評(píng)論 5 346
  • 正文 年R本政府宣布浪蹂,位于F島的核電站,受9級(jí)特大地震影響告材,放射性物質(zhì)發(fā)生泄漏坤次。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,471評(píng)論 3 331
  • 文/蒙蒙 一斥赋、第九天 我趴在偏房一處隱蔽的房頂上張望缰猴。 院中可真熱鬧,春花似錦疤剑、人聲如沸滑绒。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,017評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽疑故。三九已至,卻和暖如春弯菊,著一層夾襖步出監(jiān)牢的瞬間纵势,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,142評(píng)論 1 272
  • 我被黑心中介騙來泰國打工管钳, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留吨悍,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,388評(píng)論 3 373
  • 正文 我出身青樓蹋嵌,卻偏偏與公主長得像育瓜,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子栽烂,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,066評(píng)論 2 355

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