Perl interaction with HTTP Proxy:

Maxim Dounin mdounin at
Thu Feb 9 08:37:35 UTC 2012


On Thu, Feb 09, 2012 at 02:30:36AM -0600, Engin Akyol wrote:

> Hey guys, I'm trying to write a couple of perl modules for my nginx
> server that is acting as an HTTP Proxy.
> What I'd like to do is use Perl to perform some (quick) checks and
> then return an error code, but I'm noticing that if I execute any perl
> code before the config block that engages the http_proxy, the perl
> error code is ignored.  If I execute the perl block after the
> http_proxy, then the connection isn't proxy passed at all.  Is this a
> config issue on my part or is this normal behavior with regards to
> perl.  If it's normal behavior, how can I use perl modules to perform
> checks with http_proxy features enabled?

Both perl and proxy set exclusive location handlers, and they 
can't be used together in the same location.

If you need to check requests with perl and then proxy_pass 
somewhere, you have to use $r->internal_redirect(uri) in perl to 
pass processing to another location with proxy_pass configured.

Maxim Dounin

More information about the nginx mailing list