post_action, just send http request, not fcgi

Rob Mueller robm at fastmail.fm
Fri Mar 7 05:33:20 MSK 2008


I'm still battling with my post_action handler. I'm having a painful time 
trying to use an FCGI handler, mostly because of the perl implementation of 
FCGI doesn't work nicely with our daemon framework which is based on 
Net::Server.

I could keep digging down that path, but I decided a MUCH easier way would 
be if post_action could just send an HTTP request to my handler, and put the 
values I want in the header, it'll be easy to pull the stuff from the 
headers.

I thought something hacky like this might work.

    location = @done {
      set    $rateuser     $upstream_http_x_rate_user;
      proxy_set_header RateUser $rateuser;
      proxy_set_header RateURI  $request_uri;
      proxy_set_header RateBytes $body_bytes_sent;
      proxy_pass http://127.0.0.1:2350;
    }

And indeed for GET requests it does nicely, I get the headers I want which I 
can quickly and easily decode them. In fact I don't really need to set 
RateURI, since the first first line of the request gives me the URI.

If I do a POST though, nginx isn't happy.

root at robmlinux:/home/mod_perl/hm# 2008/03/07 13:20:46 [warn] 23198#0: *352 a 
client request body is buffered to a temporary file 
/var/accelcache/0/00/0000000000, client: 192.168.110.1, server: xyz, 
request: "POST /testdir/ HTTP/1.1", host: "www.testmachine.com", referrer: 
"http://www.testmachine.com/testdir/"
2008/03/07 13:20:52 [crit] 23198#0: *352 pread() failed, file 
"/var/accelcache/0/00/0000000000" (9: Bad file descriptor) while sending 
request to upstream, client: 192.168.110.1, server: xyz, request: "POST 
/testdir/ HTTP/1.1", upstream: "http://127.0.0.1:2350/testdir/", host: 
"www.testmachine.com", referrer: "http://www.testmachine.com/testdir/"
2008/03/07 13:20:52 [crit] 23198#0: *352 pread() failed, file 
"/var/accelcache/0/00/0000000000" (9: Bad file descriptor) while sending 
request to upstream, client: 192.168.110.1, server: xyz, request: "POST 
/testdir/ HTTP/1.1", upstream: "http://127.0.0.1:2350/testdir/", host: 
"www.testmachine.com", referrer: "http://www.testmachine.com/testdir/"
2008/03/07 13:20:52 [crit] 23198#0: *352 pread() failed, file 
"/var/accelcache/0/00/0000000000" (9: Bad file descriptor) while sending 
request to upstream, client: 192.168.110.1, server: xyz, request: "POST 
/testdir/ HTTP/1.1", upstream: "http://127.0.0.1:2350/testdir/", host: 
"www.testmachine.com", referrer: "http://www.testmachine.com/testdir/"

Using "proxy_pass" is clearly the wrong thing here because I don't want to 
actually proxy the data again, it was just a hack to try. Really what I want 
is a simple way to say "just send a GET request to this server with these 
headers and just ignore the result, since there shouldn't be any". Is there 
any way to do that so I can skip FCGI totally in the post_action?

Rob






More information about the nginx mailing list