1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Any Nginx config experts anywhere?

Discussion in 'Server Configuration and Hosting' started by Rob, Apr 17, 2012.

  1. Rob

    Rob Well-Known Member

    Hi there,

    I have moved from apache/vb/vbseo to nginx/xenforo.

    I am struggling to optimise my nginx config file and have so far received some generous help from Floren but am now scratching my head over how to proceed further.

    I cannot pay anyone for this so I'm relying on the generosity of xenForo users to steer me in the right direction.

    What I need is to be able to optimise the following nginx config
    Code:
    #Forum 26 main
    location = /category-name-73/forum-name-26/  {
        rewrite ^ /forums/forum-name.26/ permanent;
    }
     
    #Forum 26
    location /category-name-73/forum-name-26/ {
        #forum paging
        rewrite ^/category-name-73/forum-name-26/index([\d]+).html /forums/forum-name.26/page-$1 permanent;
     
        #thread paging (modified version of kier's redirect script)
        rewrite [^/]+/([\d]+)-.+-([\d]+).html /showthread.php?t=$1&page=$2 last;
     
        #thread
        rewrite [^/]+/([\d]+)-.+.html /threads/redirectme.$1/ permanent;
    }
    I've been told that when hitting "/category-name-73/forum-name-26/" then 4 regex's will be evaluated and supposedly that is not good. If I hit a deeper url at the same path then I'm told it will evaluate 3 regex's. However, it is apparently possible to do the above using just one regex. I am purplexed as to how this would be possible and clearly want to have the most optimised config I can but I now seem stuck in no mans land.

    Can anyone please help me?
     
  2. Andy.N

    Andy.N Well-Known Member

    Deebs/darkimmortal would be able to help
     
  3. Rob

    Rob Well-Known Member

    Thank you... shame the tag me mod isnt installed here :)

    The above is just a very very small part of a huge config file migrated from a .htaccess file which rewrites old vbseo urls to xenforo under apache.

    If I can optimise just this small part then I can handle the rest of the config on my own :)
     
  4. Luke F

    Luke F Well-Known Member

  5. Rob

    Rob Well-Known Member

    Hiya,

    I was mainly trying to avoid the 4 regex calls for urls in the path above. Floren has told me there is much better way than going the above route but hasnt really gave me anything else to go on.

    I agree that the reg ex shouldn't really be that much of an overhead but I want to start out with as optimised a config as possible.

    If I can implement this with minimal reg ex use then I doubt PCRE JIT will be needed at all.

    Can the above be tweaked to make use of nested location {} elements to be 'more selective'? I can see how to select paths using forum paging, but I can't see how to select paths for threads or thread paging using just location {} as the selector. If I can sort out that bit then I can ensure just one reg ex is run per url.

    I think this thread could be extremely useful to other people who have moved to nginx and need to rewrite vbseo urls.

    Any ideas?

    Rob
     
  6. p4guru

    p4guru Well-Known Member

  7. Rob

    Rob Well-Known Member

    Hi, I have posted there but I don't hold out much hope of getting any help there looking at the other threads.
     

Share This Page