您好,登錄后才能下訂單哦!
Nginx的ngx_http_gzip_module壓縮模塊提供對文件內容壓縮的功能,允許Nginx服務器將輸出內容在發送客戶端之前進行壓縮,以節約網站帶寬,提升用戶的訪問體驗,默認已經安裝。可在配置文件中加入相應的壓縮功能參數對壓縮性能進行優化。
[root@localhost ~]# systemctl stop firewalld.service //關閉防火墻
[root@localhost ~]# setenforce 0 //關閉增強性安全功能
[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 //重啟服務
[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/ //網站圖片
[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 { //添加區域
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 //復制一份模板并重命名
[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 //開啟服務
[root@localhost named]#
<html>
<head>
<title>盜鏈網站</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]#
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。