Rewrite Performance Question

Hi,

come some take a look at these rewrite rules if they are ok regarding
performance?

    if ($host = 'forum.de' ) {
        rewrite ^/(.*)$ http://www.forum.de:81/$1 permanent;
    }

    if ($host ~* ^(www\.)??forum\.(at|ch|com|eu|info|net|org)) {
        rewrite ^(.*)$ http://www.forum.de:81 last;
    break;
    }

}

Thanks :slight_smile:

Juergen

On Mon, Jul 19, 2010 at 1:59 PM, Juergen G. [email protected]
wrote:

   if ($host ~* ^(www\.)??forum\.(at|ch|com|eu|info|net|org)) {
       rewrite ^(.*)$ http://www.forum.de:81 last;
   break;
   }

}
Hi!
Never use if ($host …
Different servers with different server_names must be used instead:
server
{
server_name forum.de;
location / { rewrite ^ http://www.forum.de:81/$request_uri?
premanent; }
}
server
{
server_name ~^(www.)??forum.(at|ch|com|eu|info|net|org);
location / { rewrite ^ http://www.forum.de:81/$request_uri?
premanent; }
}

–
Boris D…

On Mon, Jul 19, 2010 at 02:20:49PM +0400, Boris D. wrote:

server_name forum.de;
location / { rewrite ^ http://www.forum.de:81/$request_uri? premanent; }

}
server
{
server_name ~^(www.)??forum.(at|ch|com|eu|info|net|org);
location / { rewrite ^ http://www.forum.de:81/$request_uri? premanent; }
}

Also, in the second server it’s better to use usual names instead of
regex:

 server_name   forum.at www.forum.at
               forum.ch www.forum.ch
               ...
               ;

–
Igor S.
http://sysoev.ru/en/

2010/7/19 Igor S. [email protected]:

Also, in the second server it’s better to use usual names instead of regex:

Γ‚ Γ‚ server_name Γ‚ forum.at www.forum.at
Γ‚ Γ‚ Γ‚ Γ‚ Γ‚ Γ‚ Γ‚ Γ‚ Γ‚ forum.ch www.forum.ch
Γ‚ Γ‚ Γ‚ Γ‚ Γ‚ Γ‚ Γ‚ Γ‚ Γ‚ …
Γ‚ Γ‚ Γ‚ Γ‚ Γ‚ Γ‚ Γ‚ Γ‚ Γ‚ ;

it would be nice if the config supports simple (extended)
glob(3)-style pattern matching so it would be something like

server_name {www.,}forum.{at,ch,com,eu,info,net,org};

which should be automatically expanded into

www.forum.at
www.forum.ch
www.forum.com
…
forum.net
forum.org

–
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

On 19.07.2010 17:49, Edho P Arief wrote:

…
forum.net
forum.org

You can use some preprocessor to generate nginx config from template
(with
globs, variables and other features missing in nginx config)

–
Anton Y.

Ok :slight_smile: thanks to both of you

Juergen

On Tue, Jul 20, 2010 at 4:39 PM, Anton Y. [email protected]
wrote:

You can use some preprocessor to generate nginx config from template (with
globs, variables and other features missing in nginx config)

whare can I find this β€œsome preprocessor”?

–
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

www.forum.com
…
forum.net
forum.org
You can use some preprocessor to generate nginx config from template (with
globs, variables and other features missing in nginx config)

server_name ~β€œ(www.)?forum.(at|ch|com|eu|info|net|org)”;

or

server_name ~β€œ(www.|)forum.(at|ch|com|eu|info|net|org)”;

?

–
br, Denis F. Latypoff.

www.forum.com
…
forum.net
forum.org
You can use some preprocessor to generate nginx config from template (with
globs, variables and other features missing in nginx config)

  • server_name ~β€œ(www.)?forum.(at|ch|com|eu|info|net|org)”;
  • server_name ~β€œ(www.)?forum.(at|ch|com|eu|info|net|org)”;

or

  • server_name ~β€œ(www.|)forum.(at|ch|com|eu|info|net|org)”;
  • server_name ~β€œ(www.|)forum.(at|ch|com|eu|info|net|org)”;

?

br, Denis F. Latypoff.


nginx mailing list
[email protected]
nginx Info Page

–
br, Denis F. Latypoff.