Home Use variable in lua and nginx
Reply: 0

Use variable in lua and nginx

user711 Published in June 23, 2018, 5:31 pm

I have a variable $aet that I initialize in lua, but I wish I could use it in nginx too.

Here is my code:

location /getIp {
    default_type 'application/json';
    rds_json          on;

    content_by_lua '
        if ngx.var.host:match("(.*).nexus$") ~= nil then
            aet = ngx.var.host:match("(.-)%.")
            $aet = aet;
    postgres_pass     database;
    postgres_query  "SELECT ip FROM establishment_view WHERE aet = $aet";
    postgres_output rds;

It does not work because in the query it does not know the variable aet :

nginx: [emerg] unknown "aet" variable

You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO