proxy_pass fails after calling $r->has_request_body()

Ben Grimm lists at ruby-forum.com
Thu Dec 20 07:58:43 MSK 2007


Hi, I'm trying to parse a request in a perl handler, extract a value
from it and use that to set a variable for use in a proxy_pass mapping.
GET requests work fine, but POST's fail.  I suspect that the proxy_pass
is trying re-read the  request body.  Is there a better way to
accomplish do this?

location ^~ /@map/ {
   internal;
   perl ProxyMap::handler;
}

location ^~ /@backend/ {
   internal;
   proxy_pass  http://backend/;
}

#####
package ProxyMap;
sub handler {
    my $r = shift;
    return OK if $r->has_request_body(\&handle_request);
    return handle_request($r);
}
## this is reduced to the simplest example I could make
sub handle_request {
    my $r = shift;
    my $backend = 'backend';
    my $uri = $r->uri;
    $uri =~ s/\@map/\@$backend/;
    $r->internal_redirect($uri);
    return OK;
}
1;
-- 
Posted via http://www.ruby-forum.com/.





More information about the nginx mailing list