# HttpSecureLinkModule timestamp inside uri

**URL:** <https://www.ruby-forum.com/t/httpsecurelinkmodule-timestamp-inside-uri/218599>\
**Category:** NGINX\
**Created:** [April 5, 2012, 10:57am UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-timestamp-inside-uri/218599 "2012-04-05T10:57:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [April 5, 2012, 10:57am UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-timestamp-inside-uri/218599/1 "2012-04-05T10:57:24Z")

</div>

I would like to use HttpSecureLinkModule to restrict access to some  
member photos. Now I would like to have the timestamp inside the path  
but I’m not sure how to implement that.

The timestamp I could get with /t(\d+)/ from uri, must I do a rewrite  
and if yes how? Or exist a “single” operation way?

Photo-URL:  
www.example.aaa/260/7/4/3/4255/4543535/t1331894408/1234\_x.jpg?a=1234567888

location ~ \_x.(jpg|jpeg|gif|png)$ {

secure\_link $arg\_a,$???;  
secure\_link\_md5 mysecretword$uri$???;

root /media/photos  
…  
}

Posted at Nginx Forum:

> **[HttpSecureLinkModule timestamp inside uri](https://forum.nginx.org/read.php?2,224960,224960#msg-224960)**
>
> I would like to use HttpSecureLinkModule to restrict access to some member photos. Now I would like to have the timestamp inside the path but I'm not sure how to implement that. The timestamp I could get with \\/t(\\d+)\\/ from uri, must I do a rewrite...

---

<div class="post-metadata">

**Author:** ![nenad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@nenad](https://www.ruby-forum.com/u/nenad)\
**Post date:** [April 5, 2012, 2:04pm UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-timestamp-inside-uri/218599/2 "2012-04-05T14:04:58Z")

</div>

On Thursday 05 April 2012 12:56:32 nenad wrote:

> location ~ \_x.(jpg|jpeg|gif|png)$ {
> 
> secure\_link $arg\_a,$???;  
> secure\_link\_md5 mysecretword$uri$???;
> 
> root /media/photos  
> …  
> }

```
location ~ t(?P<t>\d+)/\d+_x\.(?:jpe?g|gif|png)$ {

    secure_link $arg_a,$t;
    secure_link_md5 mysecretword$uri$t;

    root /media/photos
    ...
}

```

wbr, Valentin V. Bartenev

---

<div class="post-metadata">

**Author:** ![nenad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@nenad](https://www.ruby-forum.com/u/nenad)\
**Post date:** [April 6, 2012, 3:26pm UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-timestamp-inside-uri/218599/3 "2012-04-06T15:26:19Z")

</div>

thank you, that worked!

can you also say me how i can point to correct root without /t{time},  
now it try to open the file in a folder with timestamp in.

www.example.aaa/260/7/4/3/4255/4543535/t1331894408/1234\_x.jpg?a=1234567888

means it try to open it in:  
/media/photos/260/7/4/3/4255/4543535/t1331894408/1234\_x.jpg instead  
/srv/media/260/7/4/3/4255/4543535/1234\_x.jpg

Posted at Nginx Forum:

> **[Re: HttpSecureLinkModule timestamp inside uri](https://forum.nginx.org/read.php?2,224960,225018#msg-225018)**
>
> I would like to use HttpSecureLinkModule to restrict access to some member photos. Now I would like to have the timestamp inside the path but I'm not sure how to implement that. The timestamp I could get with \\/t(\\d+)\\/ from uri, must I do a rewrite...

---

<div class="post-metadata">

**Author:** ![nenad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@nenad](https://www.ruby-forum.com/u/nenad)\
**Post date:** [April 6, 2012, 6:03pm UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-timestamp-inside-uri/218599/4 "2012-04-06T18:03:50Z")

</div>

On Friday 06 April 2012 17:25:53 nenad wrote:

> 

> **[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#alias)**
>
> This directive appeared in version 1.11.8.

```
location ~ ^(.+)/t(?P<t>\d+)(/\d+_x\.(?:jpe?g|gif|png))$ {

    secure_link $arg_a,$t;
    secure_link_md5 mysecretword$uri$t;

    alias /srv/media$1$3;
    ...
}

```

wbr, Valentin V. Bartenev
