a newbie question regarding regex in nginx conf

mike mike503 at gmail.com
Wed Sep 3 20:38:16 MSD 2008


i try to keep directories to less than 10,000 files apiece,
personally. i think nearly every filesystem it's a good idea to put a
limit on it, especially if you ever use "rm" and such - eventually the
argument list gets too long too :)


On Wed, Sep 3, 2008 at 9:11 AM, Chris Savery <chrissavery at gmail.com> wrote:
> I'm curious about your breaking up the filename into a path like that. If
> using ext3 filesystem is there any advantage speed wise to doing that? I
> thought it could handle large file counts without a problem using indexing
> but I may be wrong and I am quite interested as I expect to have thousands
> of image files as well and if it's going to be slow on ext3 then I would
> also want to split up directories like this.
> Chris :)
>
> Maxim Dounin wrote:
>
> Hello!
>
> On Wed, Sep 03, 2008 at 11:33:15PM +0800, Zhang Yining wrote:
>
> Hi list,
>
> I have a question regarding regex in nginx conf, and believe it must
> have been brought up before, yet after googling for it, I could not find
> an answer.
>
> Specifically, is it possible to use curly braces in nginx conf?
>
> For example, for some url like: /photos/123456
>
> I would want to rewrite it to: /path/to/photos/12/1234/123456.png
>
> in apache's conf rewrite rule, I could use something like:
>
> [0-9]{2}[0-9]{2}[0-9]{2}  /path/to/photos/$1/$1$2/$1$2$3.png
>
> But it seems curly braces are reserved for nginx conf file's own use,
> and not recognized by the regex processing.
>
> So is there any way to use curly braces in regex? If so, could some one
> kind enough to provide a link or short explanation of how to do it?
>
> Just quote the regex, i.e:
>
> rewrite  "([0-9]{2})([0-9]{2})([0-9]{2})"
> /path/to/photos/$1/$1$2/$1$2$3.png;
>
> (single quotes will do the trick too).
>
> It's documented in
> http://sysoev.ru/nginx/docs/http/ngx_http_rewrite_module.html#rewrite (in
> russian), but not (yet) in english wiki.  Feel free to update
> http://wiki.codemongers.com/NginxHttpRewriteModule#rewrite.
>
> Maxim Dounin
>
>
>





More information about the nginx mailing list