Order execution of module

Hello NGINX experts,

I am developing a new custom module that hooks into an NGINX processing phase. There is already another custom module (Module A) registered in the same phase.

I would like my new module to run after Module A. Both Module A and the new module are dynamic modules. I have following questions:

  1. Is there a reliable way to control the execution order between modules in the same phase and make this order consistent?
  2. Is it true that custom modules are always run after built-in module in the same phase?

Thank you.

You can specify this in the module config file
https://nginx.org/en/docs/dev/development_guide.html#:~:text=ngx_module_order

Also see Static module dependency order

I can’t help much more. It’s a hack, but you might consider putting Module A in the preaccess phase to ensure it is executed first.