盗链环境模拟

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. 关于通信的关键词UDP/(TCP/IP)/IPC/RPC/.NET Remoting/WebService/WCF/Http 系列

    OSI七层和TCP/IP四层的关系 1.1 OSI引入了服务.接口.协议.分层的概念,TCP/IP借鉴了OSI的这些概念建立TCP/IP模型. 1.2 OSI先有模型,后有协议,先有标准,后进行实践: ...

  2. Ubuntu16.04 释放/boot目录空间

    查看当前系统内核 $ uname -a Linux linuxidc --generic #-Ubuntu SMP Mon Feb :: UTC x86_64 x86_64 x86_64 GNU/Li ...

  3. ios中core Plot (2)

    #import "ViewController.h" @interface ViewController () //指定要画得view @property(nonatomic,as ...

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

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

  5. db_table--Spring Security3.1 最新配置实例

    2011-04-28 这几天学习了一下Spring Security3.1,从官网下载了Spring Security3.1版本进行练习,经过多次尝试才摸清了其中的一些原理.本人不才,希望能帮助大家. ...

  6. 【RS】Matrix Factorization Techniques for Recommender Systems - 推荐系统的矩阵分解技术

    [论文标题]Matrix Factorization Techniques for Recommender Systems(2009,Published by the IEEE Computer So ...

  7. Python 中的__new__和__init__的区别

    [同] 二者均是Python面向对象语言中的函数,__new__比较少用,__init__则用的比较多. [异] __new__是在实例创建之前被调用的,因为它的任务就是创建实例然后返回该实例对象,是 ...

  8. linux 的时区设置函数tzset() 【转】

    linux 的时区设置函数tzset() 本文转载于: http://blog.csdn.net/epicyong333/article/details/5258152 tzset #incude & ...

  9. windows下如何生成gitlab ssh公钥

    1.查看是否已经有了ssh密钥:cd ~/.ssh如果没有密钥则不会有此文件夹,有则备份删除2.生存密钥: $ ssh-keygen -t rsa -C “你的邮箱”按3个回车,密码为空. Your ...

  10. 远程首次连接mysql速度慢的解决方法:skip-name-resolve取消DNS的反向解析(转)

    PHP远程连接MYSQL速度慢,有时远程连接到MYSQL用时4-20秒不等,本地连接MYSQL正常,出现这种问题的主要原因是,默认安装的 MYSQL开启了DNS的反向解析,在MY.INI(WINDOW ...