Linux-CentOS XAMPP Apache 防盗链模块mod_auth_token的安装配置
2016-11-11 19:27
1256 查看
【1】下载
https://code.google.com/p/mod-auth-token/
【2】编译
[plain] view
plain copy
print?
rm -f configure
autoreconf -fi
automake -f
./configure
make
【3】配置httpd.conf
是否添加
[plain] view
plain copy
print?
LoadModule auth_token_module modules/mod_auth_token.so
【4】配置httpd-vhosts.conf
假名preview指向mnt。
[plain] view
plain copy
print?
Alias /preview "/mnt"
<Location /preview/>
AuthTokenSecret "s3cr3tstr1ng"
AuthTokenPrefix /preview/
AuthTokenTimeout 3600
AuthTokenLimitByIp on
</Location>
【5】编码
传入系统文件的path,返回http协议的防盗链path
[php] view
plain copy
print?
public static function get_auth_token_URI($sRelPath)
{
$secret = "s3cr3tstr1ng"; // Same as AuthTokenSecret
$protectedPath = "/preview/"; // Same as AuthTokenPrefix
$ipLimitation = true; // Same as AuthTokenLimitByIp
$hexTime = dechex(time()); // Time in Hexadecimal
// /mnt/volume1/2015/12/2/18/3/24637b61-a010-49cc-8c2d-6a0005abf2e5
$fileName = substr($sRelPath, 4); // The file to access
// Let's generate the token depending if we set AuthTokenLimitByIp
if ($ipLimitation)
{
$token = md5($secret . $fileName . $hexTime . $_SERVER['REMOTE_ADDR']);
}
else
{
$token = md5($secret . $fileName. $hexTime);
}
// We build the url
$httpOrigin = null;
if(isset($_SERVER['HTTP_ORIGIN'] ))
$httpOrigin = $_SERVER['HTTP_ORIGIN'];
else
$httpOrigin = 'http://' . $_SERVER['HTTP_HOST'];
$url = $httpOrigin . $protectedPath . $token. "/" . $hexTime . $fileName;
return $url;
}
转自 http://blog.csdn.net/aoshilang2249/article/details/50301505
https://code.google.com/p/mod-auth-token/
【2】编译
[plain] view
plain copy
print?
rm -f configure
autoreconf -fi
automake -f
./configure
make
【3】配置httpd.conf
是否添加
[plain] view
plain copy
print?
LoadModule auth_token_module modules/mod_auth_token.so
【4】配置httpd-vhosts.conf
假名preview指向mnt。
[plain] view
plain copy
print?
Alias /preview "/mnt"
<Location /preview/>
AuthTokenSecret "s3cr3tstr1ng"
AuthTokenPrefix /preview/
AuthTokenTimeout 3600
AuthTokenLimitByIp on
</Location>
【5】编码
传入系统文件的path,返回http协议的防盗链path
[php] view
plain copy
print?
public static function get_auth_token_URI($sRelPath)
{
$secret = "s3cr3tstr1ng"; // Same as AuthTokenSecret
$protectedPath = "/preview/"; // Same as AuthTokenPrefix
$ipLimitation = true; // Same as AuthTokenLimitByIp
$hexTime = dechex(time()); // Time in Hexadecimal
// /mnt/volume1/2015/12/2/18/3/24637b61-a010-49cc-8c2d-6a0005abf2e5
$fileName = substr($sRelPath, 4); // The file to access
// Let's generate the token depending if we set AuthTokenLimitByIp
if ($ipLimitation)
{
$token = md5($secret . $fileName . $hexTime . $_SERVER['REMOTE_ADDR']);
}
else
{
$token = md5($secret . $fileName. $hexTime);
}
// We build the url
$httpOrigin = null;
if(isset($_SERVER['HTTP_ORIGIN'] ))
$httpOrigin = $_SERVER['HTTP_ORIGIN'];
else
$httpOrigin = 'http://' . $_SERVER['HTTP_HOST'];
$url = $httpOrigin . $protectedPath . $token. "/" . $hexTime . $fileName;
return $url;
}
转自 http://blog.csdn.net/aoshilang2249/article/details/50301505
相关文章推荐
- Linux-CentOS XAMPP Apache 防盗链模块mod_auth_token的安装配置
- Linux-CentOS XAMPP Apache 启用GZIP压缩功能 mod_deflate的安装配置
- Centos下安装配置LAMP(Linux+Apache+MySQL+PHP)
- Linux下安装配置 Jdk1.6+Tomcat6+Apache2.2.x+jk_mod1.2 详解
- Linux下安装配置 Jdk1.6+Tomcat6+Apache2.2.x+jk_mod1.2 详解
- Apache 安装配置mod_pagespeed加速模块
- 阿里云服务器下安装LAMP环境(CentOS Linux 6.3) 安装与配置 Apache 服务
- CentOS下如何给Apache添加配置mod_evasive模块防止CC攻击
- Linux下安装配置 Jdk1.6+Tomcat6+Apache2.2.x+jk_mod1.2 详解
- CentOS安装Apache的FastCGI模块(mod_fastcgi)
- Apache mod_qos模块安装与配置
- CentOS 5.2,Linux 2.6+ 内核 ,Apache+MySQL+PHP 安装及基本配置过程记录 && 将apache安装为系统服务
- Centos下安装配置LAMP(Linux+Apache+MySQL+PHP)
- Linux下Apache安装/增加mod_rewrite模块以启用rewrite功能
- CentOS 下编译安装 Apache 并配置 SSL 模块以支持 HTTPS
- Linux下apache2及模块mod_deflate等安装和配置
- Linux下安装配置 Jdk1.6+Tomcat6.0.x+MySql5.x+Apache2.2.x+jk_mod1.2+PHP5.x 详解
- Linux下Apache安装/增加mod_rewrite模块的方法
- Linux下apache、openssl、mod_ssl安装、配置
- linux下 Apache mysql python mod_python Django 配置安装说明,绝对可以安装上的说明