Accessing backend response using nginx' Perl module

Hi,

I have a simple reverse proxy setup where a Perl module does some
processing on the request and then forwards the request via the proxy
module using an internal_redirect method. I also need to adjust the
response from the backend. This includes the headers and body.

I looked at the nginx.xs and ngx_http_perl_module.c but could not see
how it could be done (I’m still pretty new to nginx so bear with me).
I guess an output filter hook needs to written and the API exposed to
the Perl module in some way.

Can someone point me in the right direction?

Thanks,
Srebrenko

On Mon, Oct 5, 2009 at 5:07 AM, Srebrenko S. [email protected]
wrote:

Hi,

I have a simple reverse proxy setup where a Perl module does some
processing on the request and then forwards the request via the proxy
module using an internal_redirect method. I also need to adjust the
response from the backend. This includes the headers and body.

An example of using internal_redirect is the upload module:

http://www.grid.net.ru/nginx/upload.en.html

Regarding response header and body processing, I think you need an
output header filter and an output body filter here. See the core
module addition for sample code:

http://wiki.nginx.org/NginxHttpAdditionModule

Cheers,
-agentzh

On Mon, Oct 5, 2009 at 11:16 AM, agentzh [email protected] wrote:

Sorry, it seems my response was rather off-topic. Was reading too fast
and ignored the “Perl” part :stuck_out_tongue:

I dunno if the embedded Perl module could do (output) filters yet.

Cheers,
-agentzh

On 05.10.2009, at 1:07, Srebrenko S. [email protected] wrote:

the Perl module in some way.
Yep. It’ll be usefull to add a new simple configuration directive like
perl_filters on; so you can ask nginx not to involve perl interpreter
in most requests processing (such as static file sending).

Can someone point me in the right direction?
Reading the source of any simple filter module will be good.
ngx_http_addition_module is the basic example for responce processing.

I’v got some success on writing filters with javascript built in
nginx. But can’t say it’s stable for production :wink:

Thanks,
Srebrenko


Peter L.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs