Skip to content

Instantly share code, notes, and snippets.

@Hadryan
Forked from nemoTyrant/gen.php
Created June 29, 2019 15:43
Show Gist options
  • Save Hadryan/4381cc3a6c03aa966fc0383cd7578ded to your computer and use it in GitHub Desktop.
Save Hadryan/4381cc3a6c03aa966fc0383cd7578ded 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