Home How to evaluate multiple columns in nginx postgres output
Reply: 0

How to evaluate multiple columns in nginx postgres output

user1265 Published in March 18, 2018, 5:13 pm

Hi I am really new to nginx and trying to set the output in a variable so that i can use it at other places. I am querying postgres db to get the name and address in the nginx configuration so that i could use as an authorization headers in my web application.

Here is what i have achieved so far.

eval_subrequest_in_memory off;
  eval $res {
             postgres_pass database;
             postgres_query "SELECT name,address->> 'address' as add FROM 
                           employee WHERE emp_id='$empid' LIMIT 1";
             postgres_output text;
            proxy_redirect     off;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-NginX-Proxy true;
            proxy_set_header Authorization $res.add;

I want to use the value name and address something like $res.name and $res.add.

I am not sure how to achieve this. An yhelp would be appreciated.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.313678 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO