Welcome! Log In Create A New Profile

Advanced

body capture and redirect

September 11, 2018 02:00AM
Hi,
In my module, I am trying to forward the request to my server based on the
content of the request body. To acheive this, I've added a body capture
filter to capture the body. My code is something like this...

static ngx_int_t
nginx_inspect_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
{

... // extract body
if (if_content_of_interest_in_body(body, body_length)) {
ngx_str_t uri = ngx_string("/my_location");
ngx_http_internal_redirect(r, &url, NULL);
ngx_http_finalize_request(r, NGX_DONE);
return NGX_DONE;
}
...
}

I have the following conf for '/my_location':

server {
...
location / {
...
}
location /my_location {
proxy_pass http://myserver;
}
}

However, I am running into an issue with my code. The request seems to get
forwarded to my server like I expected. However, my connection seems to
hang. Looks like the server seems to be waiting to read more data from
nginx. When I interrupt my server (ctrl-c; its a simple python server), it
sort breaks out of the read loop and a response is returned. Sending the
same request to my server without sending it through my module in nginx,
behaves correctly.

Could someone more experienced in nginx, point out what I am doing wrong?
Is redirect allowed from a body filter handler? Thanks for your help in
advance.

Regards,
Dk.
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

body capture and redirect

dnj0496 874 September 11, 2018 02:00AM

Re: body capture and redirect

Maxim Dounin 366 September 11, 2018 08:56AM

Re: body capture and redirect

dnj0496 593 September 11, 2018 10:54AM

Re: body capture and redirect

dnj0496 612 September 11, 2018 03:30PM

Re: body capture and redirect

Maxim Dounin 382 September 12, 2018 11:00AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 328
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready