<div dir="ltr">Hi<div><br></div><div style>I have a custom plugin that handles rewrite (NGX_HTTP_REWRITE_PHASE). There is another plugin compiled before my plugin that also handles rewrite (HttpLuaModule). I was expecting to see that my module would rewrite after lua is done, however that is not the case. Some debugging showed that whereas my module pushed into the cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers after lua, the cmcf.phase_engine.handlers had lua *after* my module. The culprit seems to be the following:</div>
<div style><div><div><br></div></div><div><div>static ngx_int_t</div><div>ngx_http_init_phase_handlers(ngx_conf_t *cf, ngx_http_core_main_conf_t *cmcf)</div></div><div>{</div><div>..<br></div><div>        ph = cmcf->phase_engine.handlers;</div>
<div>..</div></div><div style><div>        n += cmcf->phases[i].handlers.nelts;</div><div><br></div></div><div style><div>        for (j = cmcf->phases[i].handlers.nelts - 1; j >=0; j--) {</div><div>            ph->checker = checker;</div>
<div>            ph->handler = h[j];</div><div>            ph->next = n;</div><div>            ph++;</div><div>        }</div><div>}</div><div><br></div><div style>The order is inverted here (h[j] before h[j-1]). Is this intentional or a bug?</div>
<div style><br></div><div style>Thanks!</div></div></div>