<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi,<div>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...</div><div><br></div><div><div><font face="monospace, monospace">static ngx_int_t</font></div><div><font face="monospace, monospace">nginx_inspect_body_filter(ngx_http_request_t *r, ngx_chain_t *in)</font></div><div><font face="monospace, monospace">{</font></div></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">    ... // extract body</font></div><div><font face="monospace, monospace">    if (if_content_of_interest_in_body(body, body_length)) {</font></div><div><font face="monospace, monospace">        ngx_str_t uri = ngx_string("/my_location");</font></div><div><font face="monospace, monospace">        ngx_http_internal_redirect(r, &url, NULL);</font></div><div><font face="monospace, monospace">        ngx_http_finalize_request(r, NGX_DONE);<br>        // return NGX_DONE;   // causes connection abort.</font></div><div><span style="font-family:monospace,monospace">    }</span><br></div><div><font face="monospace, monospace">    ...<br>    </font>return ngx_http_next_body_filter(r, in);</div><div><font face="monospace, monospace">}</font></div><div><br></div><div>I have the following conf for '/my_location':</div><div><br></div><div><font face="monospace, monospace">  server {</font></div><div><font face="monospace, monospace">     ...</font></div><div><font face="monospace, monospace">     location / {</font></div><div><font face="monospace, monospace">         ...</font></div><div><font face="monospace, monospace">     }</font></div><div><font face="monospace, monospace">     location /my_location {</font></div><div><font face="monospace, monospace">         proxy_pass <a href="http://myserver/" target="_blank">http://myserver</a>;</font></div><div><font face="monospace, monospace">     }</font></div><div><font face="monospace, monospace">   }</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="arial, helvetica, sans-serif">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.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Doing a redirect, using similar code in </font>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. </div><div><br></div><div><font face="arial, helvetica, sans-serif">Do I need to do anything additional to redirect in the body filter? Thanks for your help.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Regards,</font></div><div><font face="arial, helvetica, sans-serif">Dk.</font></div></div></div></div></div>