title: Use NGINX to replace body from proxy_pass
body: <p>I am new to <code>openresty/nginx</code> and am trying to replace the body the comes from an earlier call to proxy_pass with code like this:</p>
  
  <pre><code>body_filter_by_lua_block {
    ngx.arg[1] = '{"count"' .. ":2}'
    ngx.arg[2] = true
  }
  </code></pre>
  
  <p>I had originally, not had the line for <code>ngx.arg[2] = true</code>, but I would get back the body twice (does that mean the body I'm replacing has 2 chunks?). I added in the <code>ngx.arg[2] = true</code> line and now the output from the request looks good. When I deploy the <code>nginx</code> file, the service looks good for a few requests then the <code>nginx</code> requests start to hang. Is the correct/best practice for replacing the response body? What should I do instead?</p>