On Wed, Aug 20, 2008 at 12:18:42PM -0400, Sean A. wrote:
Such as?
-
Only some directives are allowed inside “if” block.
-
If you have two or more “if” blocks and their conditions are true,
then
only last block configuration will be used, they are not merged as
one
may expect:
if (true) {
configuration A
}
if (true again) {
configuration B # only this configuration will be used
}
Our entire setup is built around these right now.
Could you show example of the setup ?
On Wed, Aug 20, 2008 at 11:40:18PM +0400, Igor S. wrote:
No, they does not impact the perfomance, but they has many limits
if (true) {
configuration A
}
if (true again) {
configuration B # only this configuration will be used
}
However, this does not apply to ngx_http_directive: rewrite, return, and
set:
they will be executed in both configuration: A an B. And this may
confuse too.
On Wed, Aug 20, 2008 at 11:49:59PM +0400, Igor S. wrote:
If so, how much ?
may expect:
they will be executed in both configuration: A an B. And this may confuse too.
-ngx_http_directive
+ngx_http_rewrite_module directives
Our entire setup is built around these right now.
Could you show example of the setup ?
there is a good bit of cruft in this as it has built up over 18 months
and was started when i knew basically zip about nginx.
its also very site specific ( our software does amusing things with
urls… ), kind of the uri equivalent of how i abused strings
in the if statements below to simulate ‘and’ for nginx if.
that said, here are the important parts… as noted, its all built
around if statements… largely because
this all is already inside location blocks ( i can provide more
context if you need. )
set $dynamic 0;
set $handler “lp”;
set $real_file $request_filename;
if ( $uri ~* ^/s-([^/])/(.)$ )
{
set $has_lid 1;
set $lid $1;
set $handler $2;
set $real_file $document_root/$handler;
}
dynamics
if ( !-e $real_file )
{
set $dynamic 1;
}
if ( -e $real_file/index.i )
{
set $dynamic 1;
}
if ( $real_file ~* .(i|pl)$ )
{
set $dynamic 1;
}
next 6 lines required if no site has setup any geotargeting
if ( $geotarget = 0 )
{
set $geotarget 0;
set $geotarget_domain 0;
set $geotarget_lid 0;
}
set $dyn_geo “$dynamic:$geotarget”;
if ( $dyn_geo = ‘1:1’ )
{
rewrite (.*) http://micro.$geotarget_domain/s-
$geotarget_lid&subid=$lid/$handler redirect;
break;
}
if ( $dynamic )
{
error_page 404 = @memcache;
break;
}
if ( $has_lid )
{
rewrite ^(/s-[^/]/)(.)$ /$2;
}
On Wed, Aug 20, 2008 at 06:57:52PM -0400, Sean A. wrote:
{
}
rewrite (.*) http://micro.$geotarget_domain/s-
if ( $has_lid )
{
rewrite ^(/s-[^/]/)(.)$ /$2;
}
Your configuration is good in general.
The set’s are intended for use in “if”.