quick start on writing a module?

Maxim Dounin mdounin at mdounin.ru
Wed Jun 16 20:26:10 MSD 2010


Hello!

On Wed, Jun 16, 2010 at 05:46:32PM +0200, Piotr Sikora wrote:

> Hi,
> 
> >I believe Valery Kholodkov's eval module
> >(http://grid.net.ru/nginx/eval.en.html) would fit better here than
> >auth request module.
> >(..)
> >I believe this may be handled by eval as long as postgres module
> >is able to return something it understands.
> 
> I can't agree with you here. ngx_postgres can either return single
> value in clear text or whole result-set in RDS format (which can be
> converted to JSON using ngx_rds_json [1]). Since we need more than
> one value, we would need to either do multiple queries for each
> value or use JSON. Of course, we could extract values from JSON
> using ngx_lua [2], but this seems like quite an overhead for
> something that could be easily achieved by misusing your module.

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.

> >Something like alias /path/to/$location; should do the trick.
> 
> I tried that before suggesting "proxy_pass".
> 
> Unfortunately both "alias $location;" and "alias /$location;"
> results in "/etc/passwdindex.html" is not a directory while sending
> to client".

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.

Maxim Dounin



More information about the nginx mailing list