Mail proxy-like HTTP proxy (delegating decisions to unix socket)

Hello,

I wonder wether it is possible to use nginx as an intelligent HTTP
reverse proxy, where the intelligence relies in an outside program.
Currently there is the mail proxy module for IMAP and POP, which does
something similar: it sends the incoming parameters to an outside
program, which can decide what to do.

An interface like this would be a nice feature for the HTTP reverse
proxy.

It could send out all information to the unix socket, and the receiving
program could set variables (for example to which target machine should
the connection get proxied to), or give back status codes (eg. when the
client is not allowed to PUT, only GET, doing redirects (both inside the
URL and with HTTP status codes)).

Is there something like that for nginx? Is this doable with embedded
perl? (I think it blocks, so it’s not a good idea to make calls outside
it and while the it waits for the reponse, the whole process waits…)

Thanks,