Skip to content

Instantly share code, notes, and snippets.

@roommini
Forked from nemoTyrant/gen.php
Created August 1, 2020 09:54
Show Gist options
  • Select an option

  • Save roommini/2d5b60e8cb3f44509bee3df28221a04f to your computer and use it in GitHub Desktop.

Select an option

Save roommini/2d5b60e8cb3f44509bee3df28221a04f 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