quick start on writing a module?

Maxim Dounin mdounin at mdounin.ru
Wed Jun 16 19:27:53 MSD 2010


On Wed, Jun 16, 2010 at 05:13:40PM +0200, Piotr Sikora wrote:

> Hi,
> Maxim already answered most of your questions regarding writing a
> module like this from scratch. I would like to add that you can
> already do this, without writing new module, by misusing Maxim's
> excellent ngx_http_auth_request_module [1] and ngx_postgres [2].

I believe Valery Kholodkov's eval module 
(http://grid.net.ru/nginx/eval.en.html) would fit better here than 
auth request module.

> There are two "but":
> 1) Required "postgres_set" directive is still available only in my
> local repository. I intend to push it to GitHub today or tomorrow,
> after adding some test cases, so stay tuned :)

I believe this may be handled by eval as long as postgres module 
is able to return something it understands.

> 2) You need to use "proxy_pass" for now. Ideally, you should create
> your own mini-module that would serve static files based on
> complex_value ($location). This should be mostly copy & paste of
> "ngx_http_static_handler" from nginx's ngx_http_static_module.c.

Something like alias /path/to/$location; should do the trick.

Also, with eval it's possible to use regular rewrites instead.

Maxim Dounin

More information about the nginx mailing list