Created
May 25, 2016 05:58
-
-
Save nemoTyrant/7214069e871a6de378e1281cde363bc7 to your computer and use it in GitHub Desktop.
nginx secure link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ts = '1463646983'; | |
$hash = str_replace('=', '',strtr(base64_encode(md5('1463646983 secret', TRUE)), '+/', '-_')); // base64url | |
echo $hash; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location /uploads/ { | |
secure_link $arg_t,$arg_expires; # token, expiration timestamp | |
secure_link_md5 "$secure_link_expires secret"; | |
if ($secure_link = "") { | |
return 403; | |
} | |
if ($secure_link = "0") { | |
return 410; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment