The original post: /r/nginx by /u/Organic_Pick_1308 on 2025-03-12 12:09:10.

ngx_http_rewrite_module has directives rewrite, return, etc. I want to use directives code from other module inside my module so can do code reuse “DRY”, for example create my own directive like:

server { # important to work in this Context

mycontrol \ {)

myrewrite (/download/.*)/media/(.*)..*$ $1/mp3/$2.mp3 last; # using the core ngx_http_rewrite_module)

}

mycontrol \ {)

optional using the original ngx\http_rewrite_module)

rewrite (/download/.*)/media/(.*)..*$ $1/mp3/$2.mp3 last;)

}

}

So can avoid replicate the already functionality (I want to extend the ngx_http_rewrite_module, and others modules in my module mycontrol with more features). Any ideas ?

Update: This is about module development for nginx source code

Thanks for reading

Note repost in: stackoverflow.com/questions/79503527/use-directive-code-from-other-module-inside-my-module-nginx