nginx HttpSecureLinkModule php示例 [英] nginx HttpSecureLinkModule php example

查看:48
本文介绍了nginx HttpSecureLinkModule php示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这种配置,但是我无法使它正常工作,我很难解决这个问题.

I have this configuration but I just can't make it work, Im having a hard time trying to figure it out..

我正在尝试通过使用HttpSecureLinkModule使其具有到期时间来在nginx下获取文件服务器.

I'm Trying get a fileserver under nginx using the HttpSecureLinkModule by making it with an expiration time..

这就是我在nginx中拥有的东西:

Here's what I have in nginx:

 location /files/ {
    secure_link $arg_st,$arg_e;
    secure_link_md5 "secret$uri$arg_e";

    root /usr/share/nginx/www;
    if ($secure_link = "") {
            return 403;
    }
    if ($secure_link = 0) {
            return 410;
    }
}

现在在远程服务器中hiddenfile.php

And now In the remote server hiddenfile.php

<?php
$file="file/99/240182409124019248407098227489702";
$secret_word = "secret";
$uri_prefix = "http://domain.com/";
$time = time()+600;
$md5 = base64_encode(md5($secret_word.$file.$time, true));
$md5 = strtr($md5, '+/', '-_');
$md5 = str_replace('=', '', $md5);
$url= $uri_prefix.$file.'?st='.$md5.'&e='.$time;

?>

结果是这样的: http://domain.com/file/99/240182409124019248407098227227489702?st=94ASFASF7SAF8AF9S898& ; e = 38573287583

我进入nginx的acceess.log的全部是403错误.

All I'm getting in the nginx's acceess.log is a 403 error..

任何人都可以提供有关如何执行此操作的简单示例吗?我已经尝试了好几件事,但是没有运气.

Can anyone provide a simple example on how to do this? I've tried several things with no luck..

预先感谢...

推荐答案

这是Alexey Ten.提出的这个问题的答案.

This was the answer for this question by Alexey Ten..

$uri in nginx starts with slash and in php you miss it –  Alexey Ten 14 hours ago 

这篇关于nginx HttpSecureLinkModule php示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆