title: Use variable in lua and nginx
body: <p>I have a variable <code>$aet</code> that I initialize in lua, but I wish I could use it in nginx too.</p>
  
  <p>Here is my code:</p>
  
  <pre><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;
          end
      ';
      postgres_pass     database;
      postgres_query  "SELECT ip FROM establishment_view WHERE aet = $aet";
      postgres_output rds;
  }
  </code></pre>
  
  <p>It does not work because in the query it does not know the variable aet : </p>
  
  <blockquote>
    <p>nginx: [emerg] unknown "aet" variable</p>
  </blockquote>