question about extending nginx_perl

Roman Vasilyev roman at anchorfree.com
Sat Feb 26 02:38:37 MSK 2011


Forgot the question :)

What best way to do it? Or maybe this is doable with current embedded 
perl other way?
On 02/25/2011 03:35 PM, Roman Vasilyev wrote:
> Hi,
>
> I need to intercept cookies while it setting in upstream module. To 
> make it controllable throw reverse proxy. I want to use for this 
> purpose ngx_perl, but it contains embedding only for getting 
> headers_in  and creating headers_out. So I need ability to iterate 
> throw it at rewrite stage and iterate throw upstream.headers_out on 
> content stage.
>
> I guess nginx.conf will looks like:
>
> perl/lib/filter.pm:
>
> package filter;
> use nginx;
>
> sub handler {
>   my $r = shift;
>         while(my $header=$r->upstream->header_out_get_next()){
>             if($header->name eq 'Set-Cookie'){
>                 #do something with cookie
>                 #....
>                 $header->value("new value");
>             }
>
>   return OK;
> }
>
> 1;
> __END__
>
>
>   server {
>     location / {
>
>     perl_rewrite '
>       sub {
>         my $r = shift;
>         while(my $header=$r->header_in_get_next()){
>             if($header->name eq 'Cookie'){
>                 #do something with cookie
>                 #....
>                 $header->value("new value");
>             }
>         }
>       }
>     ';
>
>       perl  filter::handler;
>     }
>   }
>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx




More information about the nginx mailing list