Skip to content

Instantly share code, notes, and snippets.

@nemoTyrant
Created May 25, 2016 05:58
Show Gist options
  • Save nemoTyrant/7214069e871a6de378e1281cde363bc7 to your computer and use it in GitHub Desktop.
Save nemoTyrant/7214069e871a6de378e1281cde363bc7 to your computer and use it in GitHub Desktop.
nginx secure link
<?php
$ts = '1463646983';
$hash = str_replace('=', '',strtr(base64_encode(md5('1463646983 secret', TRUE)), '+/', '-_')); // base64url
echo $hash;
?>
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