Rewriting https to http

Igor Sysoev is at rambler-co.ru
Fri Jan 12 15:33:06 MSK 2007


On Fri, 12 Jan 2007, Jonathan Dance wrote:

>> The order of locaiton processing is described here:
>> http://wiki.codemongers.com/NginxHttpCoreModule#location
>
> As previously mentioned there, the documentation for this (very
> important) command is quite hard to understand and was in need of
> attention. So, after much re-reading and using Google translate on the
> Russian docs, I think I understood it and completely rewrote that
> section. I would appreciate it if Igor and the other nginx team
> members could review it to make sure it is correct.

One note:

      These strings are sorted internally from longest to shortest,
      allowing the most specific string to be matched first.

It's not correct. Please, correct my spell:

      nginx finds the longest match to conventional string.
      These strings are sorted internally in lexical order,
      so the search is terminstaed just when URI became
      lexically more than a string.

>> RewriteCond %{SERVER_PORT} ^443$
>> RewriteCond $1 !^(securedir|2ndsecuredir|3rdsecuredir)/ [NC,OR]
>> RewriteCond $1 !\.(css|gif|jpe?g|bmp|js|inc)$ [NC]
>> RewriteRule ^/(.*) http://www.example.com/$1 [R=301,L]
>
> Igor's example will work but I might recommend folding it into a
> single regex so you only have a single location block to configure,
> e.g.:
>
> location ~* 
> "^(securedir|2ndsecuredir|3rdsecuredir)|\.(css|gif|jpe?g|bmp|js|inc)$"
> {
> }
>
> This is slower than using the non-regex versions like Igor did but for
> me the convenience of a shorter configuration file outweighs the
> performance hit of a regex call... besides, the regex was going to be
> called anyway unless you use ^~ (see the docs :) ).

Of course, if your configurations for these locations are equal, you
may use one big regex.


Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list