# HttpSecureLinkModule Q?

**URL:** <https://www.ruby-forum.com/t/httpsecurelinkmodule-q/200732>\
**Category:** NGINX\
**Created:** [December 20, 2010, 11:45pm UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-q/200732 "2010-12-20T23:45:59Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikuSESS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f17d59/32.png) [@nikuSESS](https://www.ruby-forum.com/u/nikuSESS)\
**Post date:** [December 20, 2010, 11:45pm UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-q/200732/1 "2010-12-20T23:45:59Z")

</div>

Hi guys, I’m trying to configure secure link modulаr together with flv  
streaming module but without success.

Can anyone give me an example with this basic setup.  
location ~ .flv {

```
    root /store;

    flv;

}

```

the plain url is [http://127.0.0.1/subdir1/subdir2/movie.flv](http://127.0.0.1/subdir1/subdir2/movie.flv)  
subdir1/subdir2 are dynamic paths to files.  
I wan;t to protect this path and flv file with temporary url.

Posted at Nginx Forum:

> **[HttpSecureLinkModule Q?](https://forum.nginx.org/read.php?2,160061,160061#msg-160061)**
>
> Hi guys, I'm trying to configure secure link modulаr together with flv streaming module but without success. Can anyone give me an example with this basic setup. location ~ \\.flv {

---

<div class="post-metadata">

**Author:** ![izrodix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3d9bf3/32.png) [@izrodix](https://www.ruby-forum.com/u/izrodix)\
**Post date:** [December 21, 2010, 1:11am UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-q/200732/2 "2010-12-21T01:11:13Z")

</div>

see excelent example in docs:  
[http://wiki.nginx.org/HttpSecureLinkModule](http://wiki.nginx.org/HttpSecureLinkModule)

---

<div class="post-metadata">

**Author:** ![izrodix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3d9bf3/32.png) [@izrodix](https://www.ruby-forum.com/u/izrodix)\
**Post date:** [December 21, 2010, 2:51am UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-q/200732/3 "2010-12-21T02:51:40Z")

</div>

izrodix at 2010-12-21 6:44 wrote:

> ```
> flv;
> 
> }
> 
> ```
> 
> the plain url is [http://127.0.0.1/subdir1/subdir2/movie.flv](http://127.0.0.1/subdir1/subdir2/movie.flv)  
> subdir1/subdir2 are dynamic paths to files.  
> I wan;t to protect this path and flv file with temporary url.

The secure link module protect file by md5. You should add a md5 string  
in your url.

For example, the url is like this:

[http://127.0.0.1/subdir1/subdir2/movie.flv?md5=NF0H4o7SIxt\_vNa9XzzxzQ==](http://127.0.0.1/subdir1/subdir2/movie.flv?md5=NF0H4o7SIxt_vNa9XzzxzQ==)

your configuration should be:

```
location ~ \.flv {
    secure_link $arg_md5;

```

secure\_link\_md5 your\_secret\_word$uri;

if ($secure\_link = “”) {  
return 403;  
}

```
    root /store;

    flv;
}

```

The md5 hash value of “your\_secret\_word$uri” will compare with the  
string specified by “secure\_link”. If the result is the same, the  
variable of $secure\_link is ‘1’, else it’s null string.

> Posted at Nginx Forum:  
> [http://forum.nginx.org/read.php?2,160061,160061#msg-160061](http://forum.nginx.org/read.php?2,160061,160061#msg-160061)
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
Weibin Y.

---

<div class="post-metadata">

**Author:** ![izrodix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3d9bf3/32.png) [@izrodix](https://www.ruby-forum.com/u/izrodix)\
**Post date:** [December 21, 2010, 9:50am UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-q/200732/4 "2010-12-21T09:50:24Z")

</div>

Thanks, for the replies but when i test this configuration users  
continue to download files from this url  
“[http://127.0.0.1/subdir1/subdir2/movie.flv](http://127.0.0.1/subdir1/subdir2/movie.flv)” without problem.  
Nginx doesn’t return 403;

location ~ .flv {  
secure\_link $arg\_md5;  
secure\_link\_md5 your\_secret\_word$uri;

if ($secure\_link = “”) {  
return 403;  
}

root /store;

flv;  
}

nginx-0.8.54 from freebsd ports.

/usr/local/etc/rc.d/nginx configtest  
Performing sanity check on nginx configuration:  
the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok  
configuration file /usr/local/etc/nginx/nginx.conf test is successful

\_OPTIONS\_READ=nginx-0.8.54  
WITHOUT\_DEBUG=true  
WITHOUT\_DEBUGLOG=true  
WITH\_FILE\_AIO=true  
WITH\_IPV6=true  
WITHOUT\_GOOGLE\_PERFTOOLS=true  
WITH\_HTTP\_MODULE=true  
WITH\_HTTP\_ADDITION\_MODULE=true  
WITH\_HTTP\_CACHE\_MODULE=true  
WITHOUT\_HTTP\_DAV\_MODULE=true  
WITH\_HTTP\_FLV\_MODULE=true  
WITHOUT\_HTTP\_GEOIP\_MODULE=true  
WITH\_HTTP\_GZIP\_STATIC\_MODULE=true  
WITHOUT\_HTTP\_IMAGE\_FILTER\_MODULE=true  
WITHOUT\_HTTP\_PERL\_MODULE=true  
WITHOUT\_HTTP\_RANDOM\_INDEX\_MODULE=true  
WITH\_HTTP\_REALIP\_MODULE=true  
WITH\_HTTP\_REWRITE\_MODULE=true  
WITH\_HTTP\_SECURE\_LINK\_MODULE=true  
WITH\_HTTP\_SSL\_MODULE=true  
WITH\_HTTP\_STATUS\_MODULE=true  
WITHOUT\_HTTP\_SUB\_MODULE=true  
WITHOUT\_HTTP\_XSLT\_MODULE=true  
WITHOUT\_MAIL\_MODULE=true  
WITHOUT\_MAIL\_IMAP\_MODULE=true  
WITHOUT\_MAIL\_POP3\_MODULE=true  
WITHOUT\_MAIL\_SMTP\_MODULE=true  
WITHOUT\_MAIL\_SSL\_MODULE=true  
WITH\_WWW=true  
WITH\_CACHE\_PURGE\_MODULE=true  
WITHOUT\_ECHO\_MODULE=true  
WITH\_HEADERS\_MORE\_MODULE=true  
WITH\_HTTP\_ACCEPT\_LANGUAGE=true  
WITHOUT\_HTTP\_ACCESSKEY\_MODULE=true  
WITHOUT\_HTTP\_AUTH\_PAM\_MODULE=true  
WITHOUT\_HTTP\_AUTH\_REQ\_MODULE=true  
WITHOUT\_HTTP\_EVAL\_MODULE=true  
WITH\_HTTP\_FANCYINDEX\_MODULE=true  
WITHOUT\_HTTP\_GUNZIP\_FILTER=true  
WITHOUT\_HTTP\_MOGILEFS\_MODULE=true  
WITH\_HTTP\_MP4\_H264\_MODULE=true  
WITH\_HTTP\_NOTICE\_MODULE=true  
WITHOUT\_HTTP\_PUSH\_MODULE=true  
WITHOUT\_HTTP\_REDIS\_MODULE=true  
WITHOUT\_HTTP\_RESPONSE\_MODULE=true  
WITHOUT\_HTTP\_UPLOAD\_MODULE=true  
WITHOUT\_HTTP\_UPLOAD\_PROGRESS=true  
WITH\_HTTP\_UPSTREAM\_FAIR=true  
WITH\_HTTP\_UPSTREAM\_HASH=true  
WITH\_HTTP\_UPSTREAM\_KEEPALIVE=true  
WITHOUT\_HTTP\_ZIP\_MODULE=true  
WITHOUT\_MEMC\_MODULE=true  
WITHOUT\_PASSENGER\_MODULE=true  
WITHOUT\_SLOWFS\_CACHE\_MODULE=true  
WITHOUT\_SUPERVISORD\_MODULE=true  
WITHOUT\_SYSLOG\_SUPPORT=true  
WITH\_UDPLOG\_MODULE=true

Posted at Nginx Forum:

> **[Re: HttpSecureLinkModule Q?](https://forum.nginx.org/read.php?2,160061,160126#msg-160126)**
>
> Hi guys, I'm trying to configure secure link modulаr together with flv streaming module but without success. Can anyone give me an example with this basic setup. location ~ \\.flv {

---

<div class="post-metadata">

**Author:** ![izrodix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3d9bf3/32.png) [@izrodix](https://www.ruby-forum.com/u/izrodix)\
**Post date:** [December 21, 2010, 10:18am UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-q/200732/5 "2010-12-21T10:18:01Z")

</div>

izrodix at 2010-12-21 16:49 wrote:

> Thanks, for the replies but when i test this configuration users  
> continue to download files from this url  
> “[http://127.0.0.1/subdir1/subdir2/movie.flv](http://127.0.0.1/subdir1/subdir2/movie.flv)” without problem.  
> Nginx doesn’t return 403;

Are you sure the request is processed in this location? Could you show  
the debug log? ([GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/Debugging))

Meanwhile, you can config nginx like this:

location ~ .flv {  
secure\_link $arg\_md5;  
secure\_link\_md5 your\_secret\_word$uri;

if ($arg\_md5 = “”) {  
return 403;  
}

if ($secure\_link = “”) {  
return 403;  
}

root /store;

flv;  
}

> flv;  
> WITHOUT\_DEBUG=true  
> WITH\_HTTP\_GZIP\_STATIC\_MODULE=true  
> WITHOUT\_MAIL\_MODULE=true  
> WITHOUT\_HTTP\_AUTH\_PAM\_MODULE=true  
> WITHOUT\_HTTP\_UPLOAD\_MODULE=true  
> WITH\_UDPLOG\_MODULE=true
> 
> Posted at Nginx Forum:  
> [http://forum.nginx.org/read.php?2,160061,160126#msg-160126](http://forum.nginx.org/read.php?2,160061,160126#msg-160126)
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
Weibin Y.

---

<div class="post-metadata">

**Author:** ![izrodix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3d9bf3/32.png) [@izrodix](https://www.ruby-forum.com/u/izrodix)\
**Post date:** [December 21, 2010, 10:18am UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-q/200732/6 "2010-12-21T10:18:01Z")

</div>

Add expire\_time in security link.  
[http://wiki.nginx.org/HttpSecureLinkModule:](http://wiki.nginx.org/HttpSecureLinkModule:)  
secure\_link  
syntax: secure\_link $md5\_hash[,$expire\_time]  
This directive specifies the MD5 hash value and the expired time of this  
link URL’s. The $md5\_hash should be encoded by modified Base64 for URL.  
The $expired\_time is the seconds since 1970-01-01 00:00:00 UTC. If you  
did not add the $expire\_time, then the link URL will never be expired.

---

<div class="post-metadata">

**Author:** ![izrodix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3d9bf3/32.png) [@izrodix](https://www.ruby-forum.com/u/izrodix)\
**Post date:** [December 21, 2010, 12:29pm UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-q/200732/7 "2010-12-21T12:29:48Z")

</div>

Weibin Y.,  
it’s working but may be I’m doing something wrong.  
Here is what I do.

$uri\_hash = md5(‘your\_secret\_word’.‘/subdir1/subdir2/movie.flv’, true);  
$uri\_ehash = base64\_encode($uri\_hash);

this is result of uri\_ehash  
[http://127.0.0.1/subdir1/subdir2/movie.flv?md5=F96syvsfhvPq54ME2VEX4A==](http://127.0.0.1/subdir1/subdir2/movie.flv?md5=F96syvsfhvPq54ME2VEX4A==)

this show me err 403  
[http://127.0.0.1/subdir1/subdir2/movie.flv](http://127.0.0.1/subdir1/subdir2/movie.flv)

I delete some part of hash

download is complete

1. F96syvsfhvPq54ME2VEX4A==

download is complete  
2. F96syvsfhvPq54ME2VEX4A=

download is complete  
3. F96syvsfhvPq54ME2VEX4A

this show me err 403  
4.F96syvsfhvPq54ME2VEX4

Is this right ?

Posted at Nginx Forum:

> **[Re: HttpSecureLinkModule Q?](https://forum.nginx.org/read.php?2,160061,160145#msg-160145)**
>
> Hi guys, I'm trying to configure secure link modulаr together with flv streaming module but without success. Can anyone give me an example with this basic setup. location ~ \\.flv {

---

<div class="post-metadata">

**Author:** ![izrodix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3d9bf3/32.png) [@izrodix](https://www.ruby-forum.com/u/izrodix)\
**Post date:** [December 22, 2010, 3:26am UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-q/200732/8 "2010-12-22T03:26:25Z")

</div>

izrodix at 2010-12-21 19:28 wrote:

> this show me err 403  
> download is complete  
> 3. F96syvsfhvPq54ME2VEX4A
> 
> this show me err 403  
> 4.F96syvsfhvPq54ME2VEX4
> 
> Is this right ?

Yes, you are right.

The character of ‘=’ in the base64 code is the padding character, it’s  
meaningless but for pad. So if you delete the ‘=’, it’s the same string.  
see this url for detail: [Base64 - Wikipedia](http://en.wikipedia.org/wiki/Base64#Padding)

The base64 encode should be base64 for  
url([Base64 - Wikipedia](http://en.wikipedia.org/wiki/Base64#URL_applications)). It means no  
padding ‘=’ will be used and the characters of ‘+’ and ‘/’ in the base64  
string should be respectively replace by ‘-’ and ‘\_’. I don’t know if  
there is a function like base64\_encode\_url() for this encode  
transformation. You can find it or try it manually.

By the way, the string of ‘your\_secret\_word’ should be your own secret  
string. It’s used to protect anyone can’t guess the transformation  
procedure of md5 hash.

> Posted at Nginx Forum:  
> [http://forum.nginx.org/read.php?2,160061,160145#msg-160145](http://forum.nginx.org/read.php?2,160061,160145#msg-160145)
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
Weibin Y.

---

<div class="post-metadata">

**Author:** ![izrodix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3d9bf3/32.png) [@izrodix](https://www.ruby-forum.com/u/izrodix)\
**Post date:** [December 22, 2010, 4:18am UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-q/200732/9 "2010-12-22T04:18:23Z")

</div>

On 22 Dez 2010 02h25 WET, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> izrodix at 2010-12-21 19:28 wrote:
> 
> > Weibin Y.,  
> > it’s working but may be I’m doing something wrong.  
> > Here is what I do.
> > 
> > $uri\_hash = md5(‘your\_secret\_word’.‘/subdir1/subdir2/movie.flv’,true);  
> > ^^^^  
> > This is incorrect. You need the string not the raw binary format.

> > $uri\_ehash = base64\_encode($uri\_hash);

Use this instead:

$uri\_hash = md5(‘your\_secret\_word’ . ‘/subdir1/subdir2/movie.flv’);  
$uri\_ehash = str\_replace(‘=’, ‘’, strtr(base64\_encode($uri\_hash), ‘+/’,  
‘-\_’)));

— appa

---

<div class="post-metadata">

**Author:** ![izrodix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3d9bf3/32.png) [@izrodix](https://www.ruby-forum.com/u/izrodix)\
**Post date:** [December 22, 2010, 7:00am UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-q/200732/10 "2010-12-22T07:00:07Z")

</div>

I’ve updated the Wiki:  
[http://wiki.nginx.org/HttpSecureLinkModule#For\_Nginx\_version\_.E2.89.A5\_0.8.50\_-\_better\_handling\_of\_the\_MD5\_hash\_and\_adding\_expiration\_time](http://wiki.nginx.org/HttpSecureLinkModule#For_Nginx_version_.E2.89.A5_0.8.50_-_better_handling_of_the_MD5_hash_and_adding_expiration_time)

based on the discussion on this thread. Please verify it.

Thanks,  
— appa

---

<div class="post-metadata">

**Author:** ![izrodix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3d9bf3/32.png) [@izrodix](https://www.ruby-forum.com/u/izrodix)\
**Post date:** [December 22, 2010, 7:57am UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-q/200732/11 "2010-12-22T07:57:56Z")

</div>

António P. P. Almeida at 2010-12-22 13:53 wrote:

> I’ve updated the Wiki:

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

> based on the discussion on this thread. Please verify it.

I think you should add the expiration time in another argument like  
this:  
[http://example.com/p/file/top\_secret.pdf?st=vXjVzvGW4363YG1I6vb11A&e=13245277231161](http://example.com/p/file/top_secret.pdf?st=vXjVzvGW4363YG1I6vb11A&e=13245277231161)

It seems that the new secure link module(above Nginx-0.8.50) uses the  
raw binary format MD5 instead. And the php CLI is like this:  
php -r ‘print str\_replace(“=”, “”,  
strtr(base64\_encode(md5(“segredo/p/files/top\_secret.pdf13245277231161”,  
true)), “+/”, “-\_”)) . “\n”;’

And the configuration (have not tested yet):

location /p/ {  
secure\_link $arg\_st,$arg\_e; # this must match the URI part related  
to the MD5 hash and expiration  
secure\_link\_md5 segredo$uri$arg\_e; # this is how the MD5 hash is  
built from a secret token and an URI

```
## If the hash is incorrect then $secure_link is a null string.
if ($secure_link = "") {
    return 403;
}

## The current local time is greater than the specified expiration 

```

time.  
if ($secure\_link = “0”) {  
return 403;  
}

```
## If everything is ok $secure_link is 1.
## This needs to be here otherwise you'll get a 404.
rewrite ^/p/(.*)$ /p/$1 break;

```

}

> Thanks,  
> — appa
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
Weibin Y.

---

<div class="post-metadata">

**Author:** ![izrodix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3d9bf3/32.png) [@izrodix](https://www.ruby-forum.com/u/izrodix)\
**Post date:** [December 22, 2010, 8:54am UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-q/200732/12 "2010-12-22T08:54:26Z")

</div>

On 22 Dez 2010 06h56 WET, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> António P. P. Almeida at 2010-12-22 13:53 wrote:
> 
> > I’ve updated the Wiki:

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

> > based on the discussion on this thread. Please verify it.
> 
> I think you should add the expiration time in another argument like  
> this:

[http://example.com/p/file/top\_secret.pdf?st=vXjVzvGW4363YG1I6vb11A&e=13245277231161](http://example.com/p/file/top_secret.pdf?st=vXjVzvGW4363YG1I6vb11A&e=13245277231161)

> It seems that the new secure link module(above Nginx-0.8.50) uses  
> the raw binary format MD5 instead. And the php CLI is like this: php  
> -r ‘print str\_replace(“=”, “”,  
> strtr(base64\_encode(md5(“segredo/p/files/top\_secret.pdf13245277231161”,  
> true)), “+/”, “-\_”)) . “\n”;’

Yes. This differs from when using secure\_link\_secret, that uses the  
string  
form of the MD5 hash.

> return 403;  
> rewrite ^/p/(.\*)$ /p/$1 break;  
> }

Done.

Thanks,  
— appa

---

<div class="post-metadata">

**Author:** ![izrodix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3d9bf3/32.png) [@izrodix](https://www.ruby-forum.com/u/izrodix)\
**Post date:** [December 22, 2010, 8:14am UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-q/200732/13 "2010-12-22T08:14:15Z")

</div>

Hi,

may i suggest to do it like mod\_secdownload from lighttpd? Instead of  
re-inventing  
the wheel you would also have compatibility which could/would make it  
easier to  
switch.

The URL are in form of:  
$prefix/$hash/$timestamp/$path/to/file

$prefix can be anything to seperate different secret areas  
$hash is a md5hash from $secret$file$timestamp  
$timestamp is a unixtimestamp in hex  
$path/to/file is the complete path with file you want to request

On the server side you have to set variables like the expiration time,  
the secret  
and maybe the “real” path per location if you not want to have the files  
stored  
inside root to be sure that it cannot be requested by accident.

On the Serverside you would have to do the following:  
parse the url for $prefix/$hash/$timestamp/$path/to/file, convert the  
timestamp  
from hex back to unixtime and check if $unixtimestamp+$timeout \<  
$timenow,  
otherwise return 410 (gone). If not, check if provided md5hash matches  
local  
generated hash with $secret$file$timestamp where $timestamp is used from  
the  
requst (since this provides you the timestamp when the url was  
generated).

This would make clear urls (no uuencoding etc.), having expiration time,  
and  
compatibility to “other well known solution”. Having lighty beside nginx  
would  
be no problem and you could use well known code / modules for other cms  
systems  
etc. which already support mod\_secdownload.

But thats just my 2 cents…

Regards,  
Sven

Am 22.12.2010 07:56, schrieb Weibin Y.:

---

<div class="post-metadata">

**Author:** ![izrodix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3d9bf3/32.png) [@izrodix](https://www.ruby-forum.com/u/izrodix)\
**Post date:** [December 22, 2010, 1:51pm UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-q/200732/14 "2010-12-22T13:51:58Z")

</div>

On 22 Dez 2010 06h56 WET, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> if ($secure\_link = “”) {
> 
> ## This needs to be here otherwise you’ll get a 404.
> 
> rewrite ^/p/(.\*)$ /p/$1 break;  
> }

I just tested it. It works.

— appa

---

<div class="post-metadata">

**Author:** ![izrodix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3d9bf3/32.png) [@izrodix](https://www.ruby-forum.com/u/izrodix)\
**Post date:** [December 25, 2010, 9:07am UTC](https://www.ruby-forum.com/t/httpsecurelinkmodule-q/200732/15 "2010-12-25T09:07:23Z")

</div>

Thanks Guys for the replies,  
this configuration works for me.

```
location ~ ^/vstore/(?[\w\-=]+,\d+)(?/.*\.mp4)$ {
    secure_link $secure;
    secure_link_md5 $secure_link_expires.$file.SECRET;

    if ($secure_link = "") {
            return 403;
    }

    if ($secure_link = 0) {
            return 410;
    }

    alias /store$file;
    mp4;
}

```

$secret\_word = “SECRET”;  
$uri\_prefix = “[http://127.0.0.1/vstore/](http://127.0.0.1/vstore/)”;  
$file = ‘/subdir1/subdir2/file.mp4’;  
$time = time()+600;  
$secret = md5($time.‘.’.$file.‘.’.$secret\_word, true);  
$secret = strtr(base64\_encode($secret), ‘+/’, ‘-\_’);

echo $hash\_url = $uri\_prefix.$secret.‘,’.$time.$file;

Posted at Nginx Forum:

> **[Re: HttpSecureLinkModule Q?](https://forum.nginx.org/read.php?2,160061,161000#msg-161000)**
>
> Hi guys, I'm trying to configure secure link modulаr together with flv streaming module but without success. Can anyone give me an example with this basic setup. location ~ \\.flv {
