Welcome! Log In Create A New Profile

Advanced

lua possibilities/limitations

Richard Kearsley
February 13, 2011 01:16AM
Hi Guys,
I need a little help with the lua module. My ultimate aim is to import variables into nginx from outside source.
Here is my code, you can probably tell what I'm trying to do:

location /proxy {
proxy_pass http://127.0.0.1:8012/;
}

location /main {
set $myvar '';
set $limit_rate 99;
content_by_lua '
local res = ngx.location.capture("/proxy",{ args = { bla = "moo" } })
if res.status == ngx.HTTP_OK then
for k,v in pairs(res.header) do
if k == "X-Limit-Rate" then
ngx.var.myvar = v
end
end
return
else
ngx.exit(res.status)
end
';

set $limit_rate $myvar;
add_header X-Test $myvar;
add_header X-Limit $limit_rate;

}
}

The output is quite confusing:

curl -I http://localhost:101/main
HTTP/1.1 200 OK
Server: nginx/0.8.54
Date: Sun, 13 Feb 2011 03:29:00 GMT
Content-Type: application/octet-stream
Connection: keep-alive
X-Test: 100
X-Limit: 99

Am I going about this in the right way? As I say, my ultimate aim is to set a whole bunch of nginx vars from outside...

Many thanks
Richard
_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

lua possibilities/limitations

Richard Kearsley February 13, 2011 01:16AM

Re: lua possibilities/limitations

agentzh February 13, 2011 11:12PM

Re: lua possibilities/limitations

agentzh February 13, 2011 11:18PM

Re: lua possibilities/limitations

Eugaia February 14, 2011 05:38AM

RE: lua possibilities/limitations

Richard Kearsley February 14, 2011 06:50PM

Re: lua possibilities/limitations

agentzh February 14, 2011 11:32PM

Re: lua possibilities/limitations

Eugaia February 15, 2011 04:02AM

Re: lua possibilities/limitations

agentzh February 15, 2011 05:50AM

Re: lua possibilities/limitations

agentzh July 04, 2011 05:32AM

RE: lua possibilities/limitations

Richard Kearsley July 04, 2011 08:06AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 315
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready