quick start on writing a module?

Piotr Sikora piotr.sikora at frickle.com
Wed Jun 16 20:47:29 MSD 2010


Hi,

> I wrote "as long as ..." on purpose, as I have no idea what
> postrgess module is able to produce, sorry.
>
> But as long as it's able to return single value in clear text it
> should be possible to write select which will return all needed
> data separated by newlines.  This should be understood by eval
> module easily.

Oops. You're right. I didn't notice that eval module allowed multiple 
variables until now. In that case, it might be indeed a better fit than 
ngx_http_auth_request_module.

One note though, you will need to use agentzh's fork of the eval module [1], 
because ngx_postgres currently doesn't work with subrequests in memory.

> This is caused by index module and only applies when uri ends with
> '/'.  Workarounds are obvious, but I doubt they are actually
> needed in this particular case.

Yes, my previous error message was produced by index module,
but the issue exists and should be probably considered a bug:

location / {
  set    $file "/etc/passwd";
  alias  $file;
}

"GET /aaa" results in:

*4 http script var: "/etc/passwd"
*4 http filename: "/etc/passwdaaa"
*4 add cleanup: 000000020E509C88
*4 open() "/etc/passwdaaa" failed (2: No such file or directory)"
*4 http finalize request: 404, "/aaa?" a:1, c:1


This can indeed be worked-around by using:

location ~ (/.*) {
  set    $file "/etc/passwd";
  alias  $file;
}

which results in:

*2 http script var: "/etc/passwd"
*2 http filename: "/etc/passwd"
*2 add cleanup: 00000002097A0CA0
*2 http static fd: 12

>From what I can tell "ngx_http_map_uri_to_path()" always adds URI to the 
path, unless you're using captures in the location.

[1] http://github.com/agentzh/nginx-eval-module

Best regards,
Piotr Sikora < piotr.sikora at frickle.com >
 




More information about the nginx mailing list