Ranier Vf
May 17, 2019 09:06AM
Hi,
Can you try:

return ngx_http_internal_redirect(r, &url, NULL);

Best regards,
Ranier Vilela

Em qua, 15 de mai de 2019 às 21:36, Dk Jack <dnj0496@gmail.com> escreveu:

> 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. Here are the relevant parts of my code...
>
> 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; // causes connection abort.
> }
> ...
> return ngx_http_next_body_filter(r, in);
> }
>
> 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. If return NGX_DONE after
> internal redirect, I get a connection abort. If I call, next_body_filter,
> the connection seems to hang.
>
> Doing a redirect, using similar code in PREACCESS_PHASE works without any
> issues. The issue seems to happen only when I wait to read the entire body
> and perform the redirect based on the content of the body. With no body
> capture, it works fine.
>
> Do I need to do anything additional to redirect in the body filter? Thanks
> for your help.
>
> Regards,
> Dk.
> _______________________________________________
> nginx-devel mailing list
> nginx-devel@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

redirect after body capture

dnj0496 637 May 15, 2019 08:36PM

Re: redirect after body capture

Maxim Dounin 318 May 16, 2019 10:14AM

Re: redirect after body capture

Ranier Vf 374 May 17, 2019 09:06AM



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

Online Users

Guests: 280
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready