Ab testing

hi! first I wanted to say that nginx is a great product!
I am trying to use it to route my traffic with several different rules.
This
way I can do ab testing.
My rules use different inputs, like http headers and uri of the request.
I am using right now the location block with regex. But when I need to
do
something more complex (like matching the query string and http_method)
I
can’t find a way to do it as it seems like nginx doesn’t have a rich
programming language, which is reasonable. But I am sure there are ways
to
do what I want, like:

location ~ /items.* {
if ($query_string ~ .&ids=. && $request_method = GET) {
proxy_pass pool_a;
}
proxy_pass pool_b;
}

this is just an example, my rules can get more complex. what would be
the
recommended way to address this?

thanks!

jonathan

nginx doesn’t have a rich programming language :). if - it is only a new
localtion :).

see this example:

(http://markmail.org/message/yv6x3z66x3a5jdv2)
http://markmail.org/message/yv6x3z66x3a5jdv2
(http://markmail.org/message/yv6x3z66x3a5jdv2)

Thu, 7 Apr 2011 19:33:25 -0300 письмо от Jonathan L.
[email protected]:

hi! first I wanted to say that nginx is a great product!
I am trying to use it to route my traffic with several different rules.
This way I can do ab testing.
My rules use different inputs, like http headers and uri of the request.
I am using right now the location block with regex. But when I need to
do something more complex (like matching the query string and
http_method) I can’t find a way to do it as it seems like nginx doesn’t
have a rich programming language, which is reasonable. But I am sure
there are ways to do what I want, like:

location ~ /items.* {
if ($query_string ~ .&ids=. && $request_method = GET) {
proxy_pass pool_a;
}
proxy_pass pool_b;
}

this is just an example, my rules can get more complex. what would be
the recommended way to address this?

thanks!

jonathan

so there is no way to do what I am trying to do?
I see I could make rewrites. the problem with that is that it won’t be
transparent to the application underneath.
I know there is a lua module. maybe there is a way to do it with lua?

as I said, I just need to be able to match on headers and uri and decide
to
which upstream to pass the request.

location ~ /items.* {
set $ok 1;
if ($query_string !~ .&ids=.) {
set $ok 0;
}
if ($request_method != GET) {
set $ok 0;
}
if ( $ok = 1 ) {
proxy_pass http://mail.ru; (http://mail.ru:wink:
}
if ( $ok = 0 ) {
proxy_pass http://google.ru; (http://google.ru:wink:
}
}

Thu, 7 Apr 2011 20:50:15 -0300 письмо от Jonathan L.
[email protected]:

so there is no way to do what I am trying to do?
I see I could make rewrites. the problem with that is that it won’t be
transparent to the application underneath.
I know there is a lua module. maybe there is a way to do it with lua?

as I said, I just need to be able to match on headers and uri and decide
to which upstream to pass the request.

On Thu, Apr 7, 2011 at 8:42 PM, Ivan [email protected] wrote:
nginx doesn’t have a rich programming language :). if - it is only a new
localtion :).

see this example:

http://markmail.org/message/yv6x3z66x3a5jdv2
(http://markmail.org/message/yv6x3z66x3a5jdv2)

Thu, 7 Apr 2011 19:33:25 -0300 письмо от Jonathan L.
[email protected]:

hi! first I wanted to say that nginx is a great product!
I am trying to use it to route my traffic with several different rules.
This way I can do ab testing.
My rules use different inputs, like http headers and uri of the request.
I am using right now the location block with regex. But when I need to
do something more complex (like matching the query string and
http_method) I can’t find a way to do it as it seems like nginx doesn’t
have a rich programming language, which is reasonable. But I am sure
there are ways to do what I want, like:

location ~ /items.* {
if ($query_string ~ .&ids=. && $request_method = GET) {
proxy_pass pool_a;
}
proxy_pass pool_b;
}

this is just an example, my rules can get more complex. what would be
the recommended way to address this?

thanks!

jonathan


nginx mailing list
[email protected]
http://nginx.org/mailman/listinfo/nginx
(http://nginx.org/mailman/listinfo/nginx)

On Fri, Apr 8, 2011 at 6:33 AM, Jonathan L. [email protected]
wrote:

hi! first I wanted to say that nginx is a great product!
I am trying to use it to route my traffic with several different rules. This
way I can do ab testing.
My rules use different inputs, like http headers and uri of the request.
I am using right now the location block with regex. But when I need to do
something more complex (like matching the query string and http_method) I
can’t find a way to do it as it seems like nginx doesn’t have a rich
programming language, which is reasonable. But I am sure there are ways to
do what I want, like:

I’d recommend you use ngx_lua’s rewrite_by_lua or access_by_lua
directives to code up such complicated business logic. See

http://github.com/chaoslawful/lua-nginx-module

for details.

Cheers,
-agentzh

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs