[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è)功能