-
-
Save roommini/2d5b60e8cb3f44509bee3df28221a04f to your computer and use it in GitHub Desktop.
nginx secure link
This file contains hidden or 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 hidden or 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