Handy config snippet: Redirect to canonical server name

Igor Sysoev is at rambler-co.ru
Sat Aug 8 10:53:25 MSD 2009

On Sat, Aug 08, 2009 at 10:19:48AM +1000, Jeff Waugh wrote:

> <quote who="Igor Sysoev">
> > This snippet is probably handy, however, it will run useless regex for
> > every request for www.example.com. Using separate example.com server is
> > better for perfomance reason.
> Isn't the regex skipped, given that the if statement doesn't match? I do
> remember your note about "if" being a bit hacky atm though, so perhaps not.
> :-)

Sorry, I was mistaken: I meant that nginx will run useless "if":

       if ( $host != $server_name ) {

A "server_name" directive test is cheaper.

Igor Sysoev

More information about the nginx mailing list