惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy International News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Troy Hunt's Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Attack and Defense Labs
Attack and Defense Labs
S
Secure Thoughts
V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
O
OpenAI News
Cloudbric
Cloudbric
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Help Net Security
Help Net Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tenable Blog
S
Security @ Cisco Blogs
N
News and Events Feed by Topic
The Hacker News
The Hacker News
C
CXSECURITY Database RSS Feed - CXSecurity.com
宝玉的分享
宝玉的分享
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
V
Visual Studio Blog
P
Proofpoint News Feed
Webroot Blog
Webroot Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 三生石上(FineUI控件)
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
L
LangChain Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东

Rat's Blog - Apache

Linux VPS使用Webbench/Apache-ab进行网站压力测试 - Rat's Blog Apache环境强制http 301跳转https的方法 - Rat's Blog CentOS 6系统Apache环境配置SSL证书教程 - Rat's Blog apache端口被异常占用导致无法启动的解决方法 - Rat's Blog
Linux VPS下Nginx与Apache环境防盗链设置方法 - Rat's Blog
博主: Rat's · 2015-03-02 · via Rat's Blog - Apache

说明:很多人的VPS流量有限,有的人在VPS中放了一首MP3用来作为背景音乐,但被搜索引擎列为试听/下载地址,放的图片和文件地址也会别人盗用,可想而知流量会消耗多快,这时候我们需要设置防盗链来阻止这样的事发生。

方法

根据我们搭建的系统环境不同,我们在NginxApache中设置防盗链的方法也是不同的。

1、Nginx防盗链方法:

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|mp3|wav|zip|rar)$
{
valid_referers none blocked moerats.com *.moerats.com;
if ($invalid_referer)
{
return 403;
}
expires 30d;
}

在我们网站所在的配置文件conf中添加以上代码,添加后重启nginx就可以生效,网址替换成自己的。

2、Apache防盗链方法:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://moerats.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://moerats.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.moerats.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.moerats.com$ [NC]
RewriteRule .*\.(gif|jpg|jpeg|png|bmp|swf|mp3|wav|zip|rar)$ http://www.moerats.com/404.html [R,NC]

把上面代码中的网址替换成自己的,然后提交至网站的根目录.htaccess文件中添加上述代码即可生效。


版权声明:本文为原创文章,版权归 Rat's Blog 所有,转载请注明出处!

本文链接:https://www.moerats.com/archives/141/

如教程需要更新,或者相关链接出现404,可以在文章下面评论留言。

Vultr新用户注册送100美元/16个机房按小时计费,支持支付宝,【点击查看】。