您好,登錄后才能下訂單哦!
Nginx的ngx_http_gzip_module壓縮模塊提供對文件內(nèi)容壓縮的功能,允許Nginx服務(wù)器將輸出內(nèi)容在發(fā)送客戶端之前進(jìn)行壓縮,以節(jié)約網(wǎng)站帶寬,提升用戶的訪問體驗,默認(rèn)已經(jīng)安裝。可在配置文件中加入相應(yīng)的壓縮功能參數(shù)對壓縮性能進(jìn)行優(yōu)化。
[root@localhost ~]# systemctl stop firewalld.service //關(guān)閉防火墻
[root@localhost ~]# setenforce 0 //關(guān)閉增強(qiáng)性安全功能
[root@localhost ~]#
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 6;
gzip_types text/plain application/x-javascript text/css image/jpeg image/png image/gif application/xml text/javascript application/x-httpd-php application/javasrcipt application/json;
gzip_disable "MSIE [1-6]\."; //IE瀏覽器6版本以上開啟壓縮功能
gzip_vary on;
[root@localhost ~]# service nginx restart //重啟服務(wù)
[root@localhost ~]#
[root@localhost ~]# mkdir /mnt/tools
[root@localhost ~]# mount.cifs //192.168.100.50/tools /mnt/tools/
Password for root@//192.168.100.50/tools:
[root@localhost ~]# cp /mnt/tools/forbid.png /usr/local/nginx/html/ //防盜鏈圖片
[root@localhost ~]# cp picture.jpg /usr/local/nginx/html/ //網(wǎng)站圖片
[root@localhost ~]# cd /usr/local/nginx/html/
[root@localhost html]# ls
50x.html forbid.png index.html picture.jpg
[root@localhost html]#
[root@localhost html]# vim index.html
<h2>Welcome to nginx!</h2>
<img src="picture.jpg"/> //添加
[root@localhost html]#
[root@localhost html]# yum install bind -y
..........//省略安裝過程
[root@localhost html]#
[root@localhost html]# vim /etc/named.conf
options {
listen-on port 53 { any; }; //將127.0.0.1改為any
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { any; }; //將localhost改為any
[root@localhost html]#
[root@localhost html]# vim /etc/named.rfc1912.zones
zone "abc.com" IN { //添加區(qū)域
type master;
file "abc.com.zone";
allow-update { none; };
};
[root@localhost html]#
[root@localhost html]# cd /var/named/
[root@localhost named]# ls
data dynamic named.ca named.empty named.localhost named.loopback slaves
[root@localhost named]# cp -p named.localhost abc.com.zone //復(fù)制一份模板并重命名
[root@localhost named]#
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
www IN A 192.168.52.131 //添加解析地址
[root@localhost named]# systemctl start named //開啟服務(wù)
[root@localhost named]#
<html>
<head>
<title>盜鏈網(wǎng)站</title>
</head>
<body>
<h2>this is test web</h2>
<img src="http:www.abc.com/picture.jpg"/> //盜鏈路徑
</body>
</html>
[root@localhost named]# vim /usr/local/nginx/conf/nginx.conf
location ~*\.(jpg|gif|swf)$ {
valid_referers none blocked *.abc.com abc.com;
if ( $invalid_referer ) {
rewrite ^/ http://www.abc.com/forbid.png;
}
}
[root@localhost named]# service nginx restart
[root@localhost named]#
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。