Cannot get secure link with expires to work
Patrick
201904-nginx at jslf.app
Fri May 3 00:39:59 UTC 2019
On 2019-05-03 09:33, Duke Dougal wrote:
> > The secret, expiry, and uri are the same from md5 generation to the
> > cURL request?
>
> Could you please explain the question further? - I’m not sure how to check
> this thanks.
Sure. Use shell variables -- e.g.
#!/bin/bash
secret="w00w00"
uri="/html/index.html"
md5_format="%s %s %s" # must match format of secure_link_md5
now=$( date +%s )
expires=$(( $now + 3600 ))
md5=$(printf "$md5_format" $expires $uri $secret |
openssl md5 -binary | openssl base64 | tr +/ -_ | tr -d = )
url="http://127.0.0.1${uri}?md5=${md5}&expires=${expires}"
echo $url
curl -I "$url"
# nginx config
root /srv/www/localhost;
location /html/ {
secure_link $arg_md5,$arg_expires;
secure_link_md5 "$secure_link_expires $uri w00w00";
if ($secure_link = "") {
return 403;
}
if ($secure_link = "0") {
return 410;
}
}
More information about the nginx
mailing list