Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Heya,
Just came across this answer and decided to write some general guidelines for anyone who comes across this in the future despite the old question.
It’s indeed possible to register handlers in specific phases of the HTTP request handling. However, controlling the exact ordering of handlers in a specific phase might be rather tricky, as it often depends on the order of module initializations.
Nginx does not provide a built-in facility for ordering handlers within a phase. Handlers are generally called in the order they were registered. And that order can depend on the order in which modules are listed during Nginx compilation.
You can experiment with adjusting the order of module initializations, but please note it could lead to unintended consequences.
If it’s crucial to have control over the exact order of handler calls, you may need to consider another design approach. A potential method could include combining the functionality of your custom module and ngx_http_realip_module into a single module if it suits your specific needs.
For more in-depth technical details, you may want to directly refer to the Nginx Development Guide.
Hope that this helps!