<div dir="ltr"><div dir="ltr"><div><div>Hi,<br></div>Can you try:<br><br></div>return <font face="monospace, monospace">ngx_http_internal_redirect(r, &url, NULL);<br><br></font></div><div><font face="monospace, monospace">Best regards,<br></font></div><div><font face="monospace, monospace">Ranier Vilela<br></font></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Em qua, 15 de mai de 2019 às 21:36, Dk Jack <<a href="mailto:dnj0496@gmail.com">dnj0496@gmail.com</a>> escreveu:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><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>
_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org" target="_blank">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a></blockquote></div>