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 <dnj0...@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

Reply via email to