nginx-0.7.18

Igor Sysoev is at rambler-co.ru
Tue Oct 21 16:31:08 MSD 2008


On Wed, Oct 15, 2008 at 09:21:55PM +0800, lhmwzy wrote:

> Still can not configure "ngx_http_secure_link_module" successfully...

The module did not work if link was less than 3 symbols ("dl").
The attached patch should fix the bug.

> 2008/10/15 lhmwzy <lhmwzy at gmail.com>:
> > Any body try "ngx_http_secure_link_module" and successful?
> > Please give me a hint.
> >
> > 2008/10/14 lhmwzy <lhmwzy at gmail.com>:
> >> I think the $secure_link is not right.
> >> when change
> >>
> >>                if ($secure_link = "") {
> >>                              return 403;
> >>               }
> >>
> >> to
> >>
> >>
> >>                if ($secure_link = "") {
> >>                              return 500;
> >>               }
> >> then the error is always 500 error.
> >> Thus we can say the $secure_link=""?
> >>
> >> 2008/10/14 lhmwzy <lhmwzy at gmail.com>:
> >>> Yes,I put a index.html file in dl directory.
> >>>
> >>> 2008/10/14 Igor Sysoev <is at rambler-co.ru>:
> >>>> On Tue, Oct 14, 2008 at 05:13:31PM +0800, lhmwzy wrote:
> >>>>
> >>>>> OK.
> >>>>> Here is my config:
> >>>>> .........
> >>>>>   location /dll/
> >>>>>         {
> >>>>>           secure_link_secret  lhm;
> >>>>>                if ($secure_link = "") {
> >>>>>                              return 403;
> >>>>>               }
> >>>>>            rewrite ^ /$secure_link  break;
> >>>>>         }
> >>>>> ............
> >>>>>
> >>>>> Then request a directory under dll
> >>>>> /dll/dl/
> >>>>>
> >>>>> md5(dllhm)=91fe55efd557140f7a32f7f7c1c74aa3
> >>>>>
> >>>>> use "http://host/dll/91fe55efd557140f7a32f7f7c1c74aa3/dl" to request,right?
> >>>>>
> >>>>> Then get "403 Forbidden"
> >>>>>
> >>>>> Any thing is wrong?
> >>>>
> >>>> Do you have index file in /dll/dl/ ? Or autoindex enabled ?
> >>>>
> >>>>> 2008/10/14 Igor Sysoev <is at rambler-co.ru>:
> >>>>> > On Tue, Oct 14, 2008 at 12:57:36PM +0400, Igor Sysoev wrote:
> >>>>> >
> >>>>> >> On Tue, Oct 14, 2008 at 04:40:29PM +0800, lhmwzy wrote:
> >>>>> >>
> >>>>> >> > Still not ok.........
> >>>>> >> > I am confused.......
> >>>>> >
> >>>>> > -    rewrite  ^   $secure_link   break;
> >>>>> > +    rewrite  ^   /$secure_link  break;
> >>>>> >
> >>>>> >> What do you get 404 or 403 ?
> >>>>> >> If the former,  what in your error_log ?
> >>>>> >>
> >>>>> >> > 2008/10/14 Igor Sysoev <is at rambler-co.ru>:
> >>>>> >> > > On Tue, Oct 14, 2008 at 04:10:58PM +0800, lhmwzy wrote:
> >>>>> >> > >
> >>>>> >> > >> Also not right.
> >>>>> >> > >> I can not get the right thing.
> >>>>> >> > >> Can you give me an example?
> >>>>> >> > >
> >>>>> >> > > You also need a "rewrite" to replace an URL with a link itself only:
> >>>>> >> > >
> >>>>> >> > >   location /dl/
> >>>>> >> > >        secure_link_secret  lhm;
> >>>>> >> > >        if ($secure_link = "") {
> >>>>> >> > >            return 403;
> >>>>> >> > >        }
> >>>>> >> > >     }
> >>>>> >> > >
> >>>>> >> > >     root  /path/to/files;
> >>>>> >> > >
> >>>>> >> > >     rewrite  ^   $secure_link  break;
> >>>>> >> > >  }
> >>>>> >> > >
> >>>>> >> > >
> >>>>> >> > >> 2008/10/14 Anton Yuzhaninov <citrin at citrin.ru>:
> >>>>> >> > >> > On 14.10.2008 08:53, lhmwzy wrote:
> >>>>> >> > >> >>
> >>>>> >> > >> >> I have set a secure link:
> >>>>> >> > >> >>  location /dl/
> >>>>> >> > >> >>        {
> >>>>> >> > >> >>         secure_link_secret  lhm;
> >>>>> >> > >> >>            if ($secure_link == "") {
> >>>>> >> > >> >>                        return 503;
> >>>>> >> > >> >>             }
> >>>>> >> > >> >>        }
> >>>>> >> > >> >>
> >>>>> >> > >> >>
> >>>>> >> > >> >> Then
> >>>>> >> > >> >> md5(dllhm)=91fe55efd557140f7a32f7f7c1c74aa3
> >>>>> >> > >> >>
> >>>>> >> > >> >> Then access it through
> >>>>> >> > >> >> http://host/91fe55efd557140f7a32f7f7c1c74aa3/dl/,but get a 404.
> >>>>> >> > >> >>
> >>>>> >> > >> >
> >>>>> >> > >> > URL should be under location /d1/ e. g.
> >>>>> >> > >> >
> >>>>> >> > >> > http://host/d1/7a701b100383d50fc2995ed264add62a/some_url_to_protected_resource
> >>>>> >> > >> >
> >>>>> >> > >> > $ echo -n some_url_to_protected_resourcelhm | md5
> >>>>> >> > >> > 7a701b100383d50fc2995ed264add62a
> >>>>> >> > >> >
> >>>>> >> > >> > --
> >>>>> >> > >> >  Anton Yuzhaninov
> >>>>> >> > >> >
> >>>>> >> > >> >
> >>>>> >> > >
> >>>>> >> > > --
> >>>>> >> > > Igor Sysoev
> >>>>> >> > > http://sysoev.ru/en/
> >>>>> >> > >
> >>>>> >> > >
> >>>>> >>
> >>>>> >> --
> >>>>> >> Игорь Сысоев
> >>>>> >> http://sysoev.ru
> >>>>> >
> >>>>> > --
> >>>>> > Игорь Сысоев
> >>>>> > http://sysoev.ru
> >>>>> >
> >>>>> >
> >>>>
> >>>> --
> >>>> Igor Sysoev
> >>>> http://sysoev.ru/en/
> >>>>
> >>>>
> >>>
> >>
> >

-- 
Igor Sysoev
http://sysoev.ru/en/
-------------- next part --------------
Index: src/http/modules/ngx_http_secure_link_module.c
===================================================================
--- src/http/modules/ngx_http_secure_link_module.c	(revision 1598)
+++ src/http/modules/ngx_http_secure_link_module.c	(working copy)
@@ -113,7 +113,7 @@
 
     len = last - p;
 
-    if (end - start != 32 || len < 3) {
+    if (end - start != 32 || len < 1) {
         goto not_found;
     }
 


More information about the nginx mailing list