1、在網(wǎng)站發(fā)布目錄下編輯html文件并準(zhǔn)備一張圖片名為33.jpg,這里網(wǎng)站發(fā)布目錄為/web1
vim /web1/index.html
<html>
<head>
<meta charset=utf-8>
<title>hostphoto.com</title>
</head>
<body>
<center><img src=33.jpg alt=fangxi width=1000px height=900px /></center>
</body>
</html>
2、編輯nginx子配置文件
location / {
root /web1;
index index.html index.htm;
valid_referers none blocked 192.168.16.150;
if ($invalid_referer) {
return 403;
}
}
? none : 允許沒(méi)有http_refer的請(qǐng)求訪問(wèn)資源;
? blocked : 允許不是http://開頭的,不帶協(xié)議的請(qǐng)求訪問(wèn)資源—被防火墻過(guò)濾掉的;
? server_names : 只允許指定ip/域名來(lái)的請(qǐng)求訪問(wèn)資源(白名單);
3、檢查配置文件是否有錯(cuò)誤,沒(méi)有錯(cuò)誤重新加載。
nginx -t
nginx -s reload
四、配置要盜用的服務(wù)器
1、配置nginx訪問(wèn)頁(yè)面并創(chuàng)建目錄
location / {
root /web1;
index index.html index.htm;
}
mkdir /web1
2、創(chuàng)建頁(yè)面
vim /web1/index.html
<html>
<body >
<img src=https://cache.yisu.com/upload/information/20200309/28/29438.jpg />
</body>
</html>
五、測(cè)試
當(dāng)開啟防盜鏈時(shí),訪問(wèn)要盜用的服務(wù)器,圖片顯示不出來(lái)。
當(dāng)把防盜鏈代碼注釋之后,訪問(wèn)要盜用的服務(wù)器,圖片就可以顯示出來(lái)。
更多關(guān)于云服務(wù)器,域名注冊(cè),虛擬主機(jī)的問(wèn)題,請(qǐng)?jiān)L問(wèn)西部數(shù)碼官網(wǎng):youyuetrip.com