FRiCKLE pres. ngx_postgres

Piotr Sikora piotr.sikora at
Thu May 6 20:33:10 MSD 2010


> I can imagine one scenario where similar plugins (polling backends for 
> info) would be useful, where nginx can act as a traffic router, something 
> like:
> $backend = select backend from route_table where host='$http_host'
> proxy_pass http://$backend
> By looking at the docs I'm guessing this isn't possible at the moment (as 
> well as the docs for ngx_drizzle, ...) - but are there any plans for 
> similar behavior?

This is indeed good use case for ngx_databases. I was solving such problem 
in the past (before ngx_drizzle was released), but I totally forgot about it 
while developing ngx_postgres. Thanks for the reminder ;)

Anyway, I've just pushed changes into ngx_postgres's GitHub repository [1] 
and this is now possible. Please note that you'll need agentzh's fork of 
eval module [2] to be able to use it with ngx_postgres.

This, along with some other changes, will be released as ngx_postgres-0.2 
early next week.

location / {
    eval_subrequest_in_memory off;

    eval $backend {
        postgres_pass       database;
        postgres_query      "select * from backends limit 1";
        postgres_get_value  0 0;

    proxy_pass $backend;


Best regards,
Piotr Sikora < piotr.sikora at >

More information about the nginx mailing list