盗链环境模拟

http://www.daolian.com/index.html 这个页面盗用http://www.maotai.com/qq.jpg这个站点页面的图.

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>毛台</title>
</head>
<body>
<h1>maotai</h1>
<p><img src="http://www.maotai.com/qq.jpg"></p>
</body>
</body>
</html>

搭建2个虚拟主机:

http://www.maotai.com/qq.jpg
http://www.daolian.com/index.html, 这个盗用上面那个站点的图.
worker_processes  1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.maotai.com;
location / {
root html;
index index.html index.htm;
}
} server {
listen 80;
server_name www.daolian.com;
location / {
root html/www;
index index.html index.htm;
}
}
}

访问测试

防盗链效果

  • 拓扑图

  • 要实现的效果
(n1)www.maotai.com/qq.jpg
(n1)www.daolian.com #实现效果: 盗用qq.jpg链接时, 将盗链的连接改为www.192.168.14.12/404.jpg (n2)www.192.168.14.12/404.jpg
  • n1访问qq.jpg正常访问时候没问题

  • 盗链服务器访问

未盗链时应该是这样的

nginx.conf

worker_processes  1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.maotai.com maotai.com;
location / {
root html;
index index.html index.htm;
}
location ~* \.(gif|jpg|png|swf|flv)$ {
valid_referers none blocked *.maotai.com;
if ($invalid_referer) {
rewrite ^/ http://192.168.14.12/404.jpg; #注这里要重新找台服务器, 如果同一台,我没做出效果
#return 404;
}
} } server {
listen 80;
server_name www.daolian.com;
location / {
root html/www;
index index.html index.htm;
}
}
}

Module ngx_http_referer_module

Nginx软件优化

完美的nginx图片防盗链设置详解

[nginx]盗链和防盗链场景模拟实现的更多相关文章

  1. nginx的优化和防盗链

    nginx的优化和防盗链 目录 nginx的优化和防盗链 一.nginx的优化 1. 隐藏版本号 (1)隐藏版本号的原因 (2)查看版本号的方法 (3)隐藏方法一:修改配置文件 (4)隐藏方法二:修改 ...

  2. nginx rewrite重写与防盗链配置

    nginx rewrite重写规则与防盗链配置方法 时间:2016-02-04 15:16:58来源:网络 导读:nginx rewrite重写规则与防盗链配置方法,rewrite规则格式中flag标 ...

  3. Nginx的优化与防盗链

    Nginx的优化与防盗链 1.隐藏版本号 2.修改用户与组 3.缓存时间 4.日志切割 5.连接超时 6.更改进程数 7.配置网页压缩 8.配置防盗链 9.fpm参数优化 1.隐藏版本号: 可以使用 ...

  4. Nginx防盗链的3种方法 文件防盗链 图片防盗链 视频防盗链 linux防盗链

    Nginx 是一个很牛的高性能Web和反向代理服务器, 它具有有很多非常优越的特性: 在高连接并发的情况下,Nginx是Apache服务器不错的替代品,目前Web服务器调查显示Apache下降Ngni ...

  5. Nginx Rewrite相关功能-防盗链

    Nginx Rewrite相关功能-防盗链 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.

  6. nginx之rewrite及防盗链

    rewrite示例-自动跳转https 示例1:自动把首页的http转化成https location / { root /data/nginx/pc/html; index index.html; ...

  7. Nginx目录保护、防盗链、限速及多域名处理

    http://www.opsers.org/server/nginx-directory-protection-anti-hotlinking-processing-speed-and-multi-d ...

  8. Nginx服务器的图片防盗链

    全站的防盗链方法 在/usr/local/webserver/nginx/conf//vhost/xxxx.conf文件要添加防盗链的server段里添加下面的代码: location ~ .*\.( ...

  9. Nginx缓存功能、防盗链、URL重写

    nginx做为反向代理时,能够将来自upstream的响应缓存至本地,并在后续的客户端请求同样内容时直接从本地构造响应报文. nginx的缓存数据结构: 共享内存:存储键和缓存对象元数据 磁盘空间:存 ...

随机推荐

  1. RabbitMQ学习笔记1-hello world

    安装过程略过,一搜一大把. rabbitmq管理控制台:http://localhost:15672/   默认账户:guest/guest RabbitMQ默认监听端口:5672 JAVA API地 ...

  2. mysql从时间字符串中取出日期数据

    addtime='2016-09-03 18:12:44' substr(addtime,1,10)  as 创建日期 SUBSTR(string, string charcter, number o ...

  3. 如何在eclipse中创建.properties文件

    打开file--new--other 选择general--file--next 选择要建在哪个文件名下,然后在底部的file name后输入properities文件名,finish即可

  4. (原)luarocks更新某个模块

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6424398.html 参考网址: https://github.com/torch/nn/issues ...

  5. java非web应用修改 properties/xml配置文件后,无需重启应用即可生效---自动加载

    实现时主要使用Commons-Configuration.jar包,还需要commons-lang,disgestor,beanutils,collections等, package propFile ...

  6. 【LeetCode】3. Longest Substring Without Repeating Characters (2 solutions)

    Longest Substring Without Repeating Characters Given a string, find the length of the longest substr ...

  7. apache安装mod_ssl.so 出现 undefined symbol: ssl_cmd_SSLPassPhraseDialog错误解决

    很久很久以前,安装Apache的时候,根本没想过将来的某一天会使用到ssl,所以也就没有安装那个模块,结果今天需要用到的时候,却无从下手了. 由于在安装Apache的时候,mod_ssl.so这个文件 ...

  8. 使用Anemometer分析MySQL慢查询记录

    数据库管理员一般是用percona的toolkit工具来分析MySQL慢查询记录,但是不够直观. 下面介绍一款比较直观的工具来统计分析MySQL慢查询记录anemometer. 在使用之前需要安装pe ...

  9. 怎样看待IT界业务,技术,管理的各自比重

    怎样看待IT界业务,技术,管理的各自比重   技术是根本,业务是个人能力的体现,管理一般随意,追求简单,眼光向IBM等有优秀管理经验的大公司看齐   重点从个人的喜好.性格方面来考虑分配比重,可以加上 ...

  10. centos7 安装遇到的问题

    win7系统下安装centos7 1:首先是在U盘启动时候遇到的,Warning: /dev/root does not exist.没找到U盘的位置.这个问题两种方法,一种是去找到对应的设备名字 然 ...