Nginx postgres problem

arunh nginx-forum at
Tue Mar 4 15:15:25 UTC 2014

Hello All,

I am newbie to Nginx and I am using Nginx with PostgreSQL database.

When there is a http request to the server I want to extract one of the
input variables in the request,
query the Database and retrun the result, the variable inside the
postgres_query is empty.

But when I try to print the value of "$1" variable and also after assigning
it to the variable "$tenantID" I do get the value.

I guess in the eval block the postgres_escape is not getting set.

Can some one throw some light on this issue if I am doing something wrong.

Also is there any supporting module to use the echo statements inside the
postgres block.


Request :

location ~ ^/tenantservices/(.*)\/(.*)\/(.*)\/(.*)
echo teh complete request uri is :$request_uri;
echo The first parameter is :$1;
echo the second aprameter is :$2;

echo the third parameter is :$3;
echo the fourth param is :$4;

    set $tenantID $1;
    set $serviceName $2;
    set $userID $3;
    set $endPointName $4;
echo After setting the tenantID:$tenantID;

    eval_subrequest_in_memory  off;
    eval $max_no_clusters
        default_type 'text/plain';
        postgres_pass   tenantdatabase;
        postgres_escape $tenantURID $tenantID;
        postgres_query   "SELECT max_no_clusters FROM load_balancer WHERE
        postgres_output  value  ;
  echo MaxNoOfclusters is : $max_no_clusters;

Log message on Nginx:
2014/03/04 15:46:05 [error] 31995#0: *152 postgres: "postgres_output value"
received 0 value(s) instead of expected single value in location
"/eval_155080700" while processing result from PostgreSQL database,

Posted at Nginx Forum:,248077,248077#msg-248077

More information about the nginx mailing list