Can not get the output when i use eval module

nginx 0.8.54 ,this is my nginx conf

    location /one/ {
        eval $uid {
            set $memc_cmd incr;
            set $memc_key 'system_uid';
            set $memc_value 1;
            memc_pass 127.0.0.1:11211;
            echo 'test';

        }
        echo 'helloworld';

    }
    location /two/ {
        echo 'helloworld';
        echo_flush;
    }

when i use curl 127.0.0.1/two/ i can get the output ,
but when i curl 127.0.0.1/one/ , it just stuck there, i can not get the
output.

i checked the value of the system_uid in memcache , it really
changed .

what is the problem? many thanks.


*

On Sun, Apr 17, 2011 at 10:54 PM, notedit [email protected] wrote:

nginx 0.8.54 ,this is my nginx conf
location /one/ {
eval $uid {
set $memc_cmd incr;
set $memc_key ‘system_uid’;
set $memc_value 1;
memc_pass 127.0.0.1:11211;
echo ‘test’;

Only one content handler is allowed in a single location. The eval
block effectively creates an anonymous location and both the memc_pass
and echo directives register a content handler in the eval block
location, which is incorrect.

Also, I’d recommend you use ngx_lua’s rewrite_by_lua directive,
combined with the ngx.location.capture() lua function call to achieve
your goal, for instance:

location = /filter-spam {
internal;
proxy_pass http://blah.blah/checker;
}

location / {
rewrite_by_lua ’
local res = ngx.location.capture(“/filter-spam”)
if res.status ~= ngx.HTTP_OK or res.body == nil then
return
end
if string.match(res.body, “SPAM”) then
return ngx.redirect(“/terms-of-use”)
end
';

fastcgi_pass …;
}

this is roughly equivalent to

location / {
eval $res {
proxy_pass http://blah.blah/checker;
}
if ($res ~ ‘SPAM’) {
rewrite ^ /terms-of-use redirect;
break;
}

fastcgi_pass ...;

}

Cheers,
-agentzh