这是我正在构建的服务器系统。
- original-website.com
- duplicate-website.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
现在,我要在每个 hosts 文件中添加 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;
}
}
}
}
现在,当我打开浏览器并输入 duplicate-website.com 的 IP 地址时,我看不到图像。为什么?