這是我正在建立的伺服器系統。
- 原始網站.com
- 重複網站.com
- 不允許的重複網站.com
我將一些內容放在original-website.com 中。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>HTML 5 Boilerplate</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
This book is written by Zeal Vora. It's a good book. I am just writing filler content here.
<img src="zealvorabook.jfif"></img>
</body>
</html>
現在,我造訪duplicate-website.com 和unallowed-duplicate-website.com 並複製其中的內容,並將圖片引用到original-website.com。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>HTML 5 Boilerplate</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
This book is written by Zeal Vora. It's a good book. I am just writing filler content here.
<img src="http://original-website.com/zealvorabook.jfif"></img>
</body>
</html>
相同的內容被貼到unallowed-duplicate-website.com
現在,我將 IP 與網域映射新增至每個主機檔案。像這樣:
192.168.1.75 duplicate-website.com
192.168.1.76 original-website.com
192.168.1.74 unallowed-duplicate-website.com
然後,我去/etc/nginx/conf.d/original-website.conf
#original-website.conf
server{
listen 80;
server_name original-website.com;
location / {
root /usr/share/nginx/html/;
location ~* \.(jpg|png|gif|jfif)$ {
valid_referers none duplicate-website.com;
if ($invalid_referer) {
return 403;
}
}
}
}
現在,當我進入瀏覽器並輸入重複網站的 IP 位址時,我看不到該圖像。為什麼?