openresty / lua-nginx-module Goto Github PK
View Code? Open in Web Editor NEWEmbed the Power of Lua into NGINX HTTP servers
Home Page: https://openresty.org/
Embed the Power of Lua into NGINX HTTP servers
Home Page: https://openresty.org/
This is more of a question than an issue...
I've been playing with the idea of making an nginx module to route requests via a 0MQ socket, instead of the regular http proxy method: https://github.com/igrigorik/zeroconf-router/tree/master/nginx
The above example is minimal, at best, but it illustrates the basic functionality. By leveraging XREQ/XREP sockets, we can decouple the backend from frontend server and skip on the entire configuration step. The current gotcha, and the reason for my questions is: as implemented in that example, the ZMQ socket read/writes are done outside of the main nginx reactor, which will obviously cause problems. 0MQ does allow us to get an FD, so I'm wondering if it would be somehow possible to feed that FD into the main reactor loop via the lua module? And then get notifications of incoming messages...
Not one to one, but an example of 0MQ + event loop: https://github.com/Neopallium/lua-zmq/blob/master/examples/ev_subscriber.lua
Thoughts, ideas, comments? :-)
Hi,
I'm experiencing a very strange behavior of 0.2.1rc2 with nginx 1.0.5 . Issuing a first request that invokes lua code works fine. However, repeating the exact same request a 2nd time fails due to calling a function that is now nil (it wasn't nil in the first invocation). The function is originally defined in a file that is "require"d by the lua file that is called by nginx (via rewrite_by_lua_file) . Oddly, when setting "lua_code_cache off" everything works ok!
Is this a known problem?
Hello
In one script called but ngx_lua, i'm doing some pattern matching, but it does not behave as expected. I'm launching this expression : string.match('http://www.example.com/iop','http://.*\.?example.com')
but it returns nil
any idea ?
I'm not able to compile nginx (1.0.1) with the lua-nginx-module on ArchLinux which has GCC 4.6.0.
It's the same problem as it was in nginx 1.0.0 itself with this gcc-version before. A workaround was and still is to remove the -Werror flag from objs/Makefile after configuring.
(For nginx 1.0.0 and gcc Igor Sysoev posted a solution on the mailinglist - don't know if it would help somehow... http://forum.nginx.org/read.php?2,194033 )
This is the error:
/home/moody/Development/Sources/lua-nginx-module/src/ngx_http_lua_hook.c: In function ‘ngx_http_lua_ngx_req_header_set_helper’:
/home/moody/Development/Sources/lua-nginx-module/src/ngx_http_lua_hook.c:2203:34: error: variable ‘ctx’ set but not used [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors
make[1]: *** [objs/addon/src/ngx_http_lua_hook.o] Error 1
make[1]: Leaving directory `/home/moody/Development/Sources/nginx-1.0.1'
make: *** [build] Error 2
like php SESSION?
Hi,
When using Lua 5.1.4 to do subrequests (e.g. ngx.location.capture() -> memc_pass), after the first or second subrequest, I've found that that I've had a host of problems, including:
As mentioned in another post, I've been doing a lot of hacking, and didn't do any checking without my code compiled-in. However, when I switched to LuaJIT, these issues went away.
I don't know how interested you are in supporting 5.1.4 since you're using JIT, but just in case you were, I thought I'd pass it on. I'm afraid I haven't got the time to look into it in any more depth myself right now.
Cheers,
Marcus.
Right now location capture is done in the background, but you're limited to issuing one request at a time. If you need to pull data from multiple sources, your page is as slow as the sum of all subrequests, but would be reduced to just the slowest if they could be issued in parallel.
If a table were passed to location.capture like this, then it would respond with an identical table of res objects.
res = ngx.location.capture({ "http://this/...", "http://that/...", "http://..." })
ngx.print( res[0].body, res[1].body, res[2].body )
Or it may be easier to use a separate function (e.g. capture_multi).
I actually have two questions related to querystring vars, those are just to start a discussion :)
First I was wondering why you prefix the variables with 'arg_' when they are accessed with ngx.var["arg_num"] for example. Is this the way nginx stores them internally ? I thought it could make more sense to just use ngx.var["num"], this way no need to prefix variable names with "arg_". I realize this is a BC break though, so maybe having ngx.vars["num"] or like with PHP, ngx._get["num"] and ngx._post["num"] to make a difference between variables from GET, POST (and COOKIE, ENV actually...).
Then, I was wondering if there was a way to deal with request vars with the same name, for example : ?num=1&num=2
IIRC, mod_lua from Apache 2.4 converts the variable to a table in this case. PHP on the other side insist on having brakets like this : ?num[]=1&num[]=2 which can be handy because it also works with num[x]=1&num[y]=2 to create an associative array.
Maybe all of this could be done on the Lua side if I parse ngx.var["request_uri"] or the body. I just thought it could be easier if it was done in the module directly.
Hi.
$ export LUAJIT_LIB=/home/tom/Applications/LuaJIT-2.0.0.beta5/lib
$ export LUAJIT_INC=/home/tom/Applications/LuaJIT-2.0.0.beta5/include/luajit-2.0
$ ./configure --prefix=/home/tom/Applications/nginx-0.8.53 --add-module=/home/tom/Downloads/ngx_devel_kit --add-module=/home/tom/Downloads/lua-nginx-module
$ make -j
$ make install
$ /home/tom/Applications/nginx-0.8.53/sbin/nginx
nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory
$
Is it possible to use ngx.location.capture to make a subrequest to a location within a different server directive from the original request? If not, is this a limitation of nginx's subrequest capabilities or is it possible to modify this module allow this?
I'd like to do something along the lines of:
ngx.location.capture('/path', { host = 'example.com' })
Where example.com matches a server_name directive in the config.
Thanks!
Hello
where should i put lua_require
http { lua_package_path './?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/lib/lua/5.1/?.lua;/usr/local/lib/lua/5.1/?/init.lua;/usr/share/lua/5.1/?.lua; /usr/share/lua/5.1/?/init.lua;/home/deploy/src/www/lib/?.lua'; lua_require 'some_library';
I put it there, but i got this error : [emerg]: unknown directive "lua_require" in /usr/local/etc/nginx/nginx.conf:22
Should i put this directive somewhere else ?
编译时发生如下错误:
ake -f objs/Makefile
make[1]: Entering directory /root/nginx-0.7.65' gcc -c -DNDK -DNDK_SET_VAR -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules -I /root/nginx-module/simpl-it-ngx_devel_kit-7ccc46d -I /root/nginx-module/simpl-it-ngx_devel_kit-7ccc46d/src -I /root/nginx-module/simpl-it-ngx_devel_kit-7ccc46d/src/auto -I src/mail \ -o objs/addon/src/ngx_http_lua_util.o \ /root/nginx-module/lua-nginx-module/src/ngx_http_lua_util.c gcc -c -DNDK -DNDK_SET_VAR -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules -I /root/nginx-module/simpl-it-ngx_devel_kit-7ccc46d -I /root/nginx-module/simpl-it-ngx_devel_kit-7ccc46d/src -I /root/nginx-module/simpl-it-ngx_devel_kit-7ccc46d/src/auto -I src/mail \ -o objs/addon/src/ngx_http_lua_cache.o \ /root/nginx-module/lua-nginx-module/src/ngx_http_lua_cache.c /root/nginx-module/lua-nginx-module/src/ngx_http_lua_util.c: In function ‘ngx_http_lua_var_get’: /root/nginx-module/lua-nginx-module/src/ngx_http_lua_util.c:320: 错误:提供给函数 ‘ngx_http_get_variable’ 的实参太少 make[1]: *** [objs/addon/src/ngx_http_lua_util.o] 错误 1 make[1]: *** 正在等待未完成的任务.... make[1]: Leaving directory
/root/nginx-0.7.65'
make: *** [build] 错误 2
环境:
CentOS 5.3
nginx-0.7.65
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
ReadMe文件中所说的三个模块均是从github上下载的最新tar包
Hi,
I had a problem caused by not adding package.seeall to my module declarations, but I've solved it.
Marcus.
In "Nginx API for Lua" -- "Core constants", there are 4 constants .
But there are no any infomation ahout how to use them.
So, how to use them ? Are they as same as NGX_OK/NGX_AGAIN/NGX_DONE/NGX_ERROR ??
when I use the method that capture ort capture_mutl, i can't get upstream_addr in nginx log,
log format is: log_format UPSTREAM "$upstream_addr".
how to get upstream_addr use of capture.
thanks!
i use require like:
local xxx = require('xxx')
but,it also haven't to work.
--test.lua
function a()
ngx.print("test.lua");
end;
a();
--concat.lua
local test=require("test");
at the first request,it print:
test.lua
and,the next time,have nothing print;
Hello!
I am using the following configuration.
location /sub {
proxy_pass http://origin-server/;
}
location /p{
echo_location /sub;
}
location / {
access_by_lua '
ngx.exec("/p")
';
}
For each client request the origin server gets two requests from the nginx. Also, the client gets two copies of the response:
Test server.
Test server.
configuration:
#./sbin/nginx -V
nginx: nginx version: nginx/1.0.2
nginx: built by gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
nginx: configure arguments: --add-module=../agentzh-echo-nginx-module-4b30897 --add-module=../chaoslawful-lua-nginx-module-1ab26d0 --with-debug
#uname -a
Linux android20 2.6.32-24-server #39-Ubuntu SMP Wed Jul 28 06:21:40 UTC 2010 x86_64 GNU/Linux
cat /etc/issue
Ubuntu 10.04.1 LTS \n \l
Hi,
the topic is a bit misleading, but here is what i mean exactly:
I can hit a subrequest via ngx.location.capture() for the uri the normal request is meant for (ngx.var.uri).
Then i have e.g. a res-variable which contains res.header, res.body and res.status.
Then i can cange the contents of the variables and e.g. write the headers back to ngx.header[] ...and output the res.body via ngx.print(res.body)
BUT how can i stop the original request from being processed at all? (flush or eof won't do this, i think?)
The baseline for the explanation would be: I want to catch a request, change it, do a subrequest with the information gathered and then output the information received by the subrequest (i don't want the original request to be executed at all!)?
Is there any way to achieve this behaviour? - My attemps when trying to force the stop of the request fail...
Here's a example code what i would like to do:
if ngx.is_subrequest == false then
res = ngx.location.capture(ngx.var.uri)
for i,j in pairs(res.header) do
ngx.header[i] = j
end
ngx.print(res.body)
-- ngx.flush()
-- ngx.eof()
end
Hi,
Are you planning on implementing being able to set subrequest variables?
e.g.
ngx.location.capture {url, {args={...}, vars={...}}}
Unless I'm mistaken, you can't safely do multiple e.g. memcache lookups asynchronously by setting e.g. $memc_key from Lua because you'd have to share the variables with each subrequest, but if you do that, then you're going to set the variables for one and all the subrequests are going to have the same ones (as the last one set).
You can of course parse them as arguments, but then you have to unescape them before you send them to memcached.
You might also want to consider giving the option to copy the parent request's variables, as well as zeroing them and sharing them.
I'm a bit busy to do it right now, but if you've not done it later on, I'll do it.
Cheers,
Marcus.
I've got something like the following
-- test.lua
local xxx = require("xxx")
-- xxx.lua
module("xxx", package.seeall)
local yyy = require("yyy")
-- yyy.lua
module("yyy", package.seeall)
local rocks = require("luarocks.loader")
local md5 = require("md5")
When I do this, I get the following error:
2011/04/05 21:59:32 [error] 38737#0: *93 lua handler aborted: runtime error: /usr/local/share/lua/5.1/luarocks/path.lua:244: stack overflow, client: 127.0.0.1, server: localhost, request: "GET /ex?name=test&count=1 HTTP/1.1", host: "localhost:8080"
The yyy.lua module works fine from a non-nginx script.
Thanks!
You say "WATCH OUT: Globals WON'T persist between requests" - thats true, but if you really want them to you can assign them to _G directly and they will persist.
I think it is probably nicer to have an explicit Lua initialisation config though...
please!
local str=ngx.escape_uri('你好')
--str is '%e4%bd%a0%e5%a5%bd%ef%bc%81'
ngx.print(ngx.unescape_uri(str));
---result is '浣犲ソ锛?'
why?
I have a dev server which is ubuntu 10.10 64 bits.
I have installed nginx 1.0.5 with lua-nginx-module and lua-redis-parser.
I have the same setup on another dev server which run centos 5.4.
On both server I run this piece of lua code.
content = ngx.location.capture("/content", {args = ngx.var.args});
if content.status == 302 or content.status == 301 then
-- ngx.redirect(content.header["Location"], content.status);
ngx.exec(content.header["Location"]);
end
The url contained in content.header["Location'] is like "/user/redirect?test=1"
On the first server, it run without problem when ngx.redirect() is used but created a "400 Bad Request" when ngx.exec() is used
On the second server, ngx.redirect() create a "400 Bad Request" and hang when ngx.exec() is used.
In both case I use the latest version of nginx and lua-nginx-module from git.
Any way I can figured out why the behavior is different and why it doesn't work overall?
Thanks for your help.
Olivier
--conf/test.lua
ngx.print(ngx.var.content_type);--error
ngx.print(ngx.var.http_cookie);--error
ngx.print(ngx.var.remote_addr);--success
不知道什么原因,请指教!
ok, first - don't try to find a sense in this code - but it does not behave as it is expected:
i have a php-script which is used via fastcgi in nginx and will only execute this:
<?php
setcookie("TestCookie1", "foo");
setcookie("TestCookie2", "bar");
phpinfo();
?>
When using rewrite_by_lua_file with this code something unexpected happens:
if ngx.is_subrequest == false then
ngx.header["Set-Cookie"] = {}
res = ngx.location.capture(ngx.var.uri)
for i,j in pairs(res.header) do ngx.header[i] = j end
ngx.send_headers()
ngx.print(res.body)
end
Normally i thought that the "for .. pairs"-part will write all response-headers from the subrequest into the ngx.header-table again. but in the Set-Cookie header only "TestCookie2" is received by the client which starts the request...
Hi,
i found some weird behaviour in ngx.header[] when i try to set a new header. When trying to set two different headers which have the same letter(s) in the beginning, one gets overwritten when setting a one-value-header. If a multiple-value header is set, the tables get mixed up... like:
ngx.header["foox"] = "foo"
ngx.header["fooy"] = "bar"
the second header won't be written, but the value of the first changed to "bar". ngx.header[] = {} has the same behaviour, but there, the tables get mixed up.
I wrote 2 tests for nginx-test which fail in my setup (nginx 1.0.2. and the latest lua-nginx-module from here):
016-resp-header.t:
=== TEST 13: names are the same in the beginning (one value per key)
--- config
location /lua {
content_by_lua '
ngx.header["Foox"] = "barx"
ngx.header["Fooy"] = "bary"
ngx.send_headers()
';
}
--- request
GET /lua
--- response_headers
Foox: barx
Fooy: bary
--- response_body
=== TEST 13: names are the same in the beginning (multiple values per key)
--- config
location /lua {
content_by_lua '
ngx.header["Foox"] = {"conx1", "conx2" }
ngx.header["Fooy"] = {"cony1", "cony2" }
ngx.send_headers()
';
}
--- request
GET /lua
--- response_headers
Foox: conx1, conx2
Fooy: cony1, cony2
--- response_body
I will try to take a look into it for myself this evening - hope i can contribute a solution :-)
Hello, thanks for the lua module contributions for Nginx. I might have 'unknown directive' issue for "set_by_lua" in the nginx.conf file after I compiled all relative modules under follow the steps in the official post. The Nginx + Lua_module seemed complied without any error, I even can see all the linking objects during compiling:
.....
objs/addon/src/ngx_http_lua_module.o
objs/addon/src/ngx_http_lua_headers.o
objs/addon/src/ngx_http_lua_directive.o
objs/addon/src/ngx_http_lua_hook.o
objs/addon/src/ngx_http_lua_util.o
objs/addon/src/ngx_http_lua_cache.o
objs/addon/src/ngx_http_lua_conf.o
objs/addon/src/ngx_http_lua_contentby.o \ ...
this is the part of block I used for testing purpose in nginx.conf:
location /inline_concat {
# MIME type determined by default_type:
default_type 'text/plain';
set $a "hello";
set $b "world";
# inline lua script
set_by_lua $res "return ngx.arg[1]..ngx.arg[2]" $a $b; # --> stop here.
echo $res;
}
Any idea?
Regards.
Hi (again),
I would like to know if you plan to add a way to set headers_out, for example header("Content-type : text/html") or ngx.request.headers_out["Content-type"] = 'text/html' ?
And maybe a way to access the request directly ?
Maybe the module is not planned to be used that way, please let me know.
Thanks.
Hi
I spoke with you over nginx mailing list yesterday
I was having problem where the request headers weren't getting passed through on a sub-request
Anyway, I got to the bottom of it:
Headers ARE passed if 'method' is left unset (it defaults to GET I assume)
But if method IS set, to ngx.HTTP_GET or ngx.HTTP_HEAD (I didnt test POST) then they are not passed through
Hope this helps & keep up the good work
.
.
.
-Wl,-E -L/opt/local/lib -lm -llua -L/opt/local/lib -lpcre -lssl -lcrypto -lz
ld: unknown option: -E
collect2: ld returned 1 exit status
make[1]: *** [objs/nginx] Error 1
make: *** [build] Error 2
ld on the MAC doesn't have a -E Removing the -E in the config breaks the build.
It would be useful to be able to read the response headers when using location.capture().
I'm having problems setting response headers. I've tried
ngx.set_header("Content-Type","text/html")
ngx.header.content_type = "text/html"
ngx.header["Content-Type"] = "text/html"
The Content-Type header is not set. Here is my location:
location /identity {
default_type text/html;
lua_need_request_body on;
client_max_body_size 10k;
client_body_in_single_buffer on;
content_by_lua_file /Users/william/biblegateway/identity/server/router.lua;
I've tried setting the headers both before and after any other response was generated, but there is nothing in the response.
Hi:
Currently, rewrite_by_lua_file cannot be used more than once. If this directive appears twice in one context, say location context, nginx -t
will report duplicate directive. If it is used in different contexts, say location and http context, only the smaller scope get executed.
So I am wondering if we can have more than one rewrite_by_lua_file. The primary reason is that separate code into different files enhance code readability and ease maintenance. Otherwise, we've to put all the rewrite stuff in one big file and this decrease the overall usability of nginx-lua module in complex environments.
Or any suggestion on how to achieve this without multiple files?
please!
Hi guys,
I'm finally getting into some ngx_lua scripting for Tagmata, so might be sending some patches to you soon.
One thing I just thought about - currently the path and cpath for searching for lua packages is at the http level. However, I can see situations where it might be really useful to be able to define it at the server level - e.g. if you're writing your own modules to be included in lots of pages on one site, but you have another site that you're doing the same on, and you don't want them to share those modules and want to completely isolate them from one another.
Do you have any plans to add this facility? Do you think it would be a relatively simple thing to do, or are there complications that you know of (e.g. problems with modules loading sub-modules which might not be the same between calls).
Cheers,
Marcus.
Hi, this is a feature request.
As I am starting to use the module more seriously, I find it painful to have to restart nginx everytime I modify a lua script when using the module with content_by_lua_file.
In Apache mod_lua, they have the following directive :
LuaCodeCache stat
LuaCodeCache forever
LuaCodeCache never
Maybe having something like that would make things easier for people like me who develop Lua websites on the fly...
Do you think this could be added to the module ?
Thank you.
This may be more of a question than an issue. I want to feed the body of one capture into another ex:
local res2 = ngx.location.capture("/cap2?"..res1.body)
However res1.body was gziped by the origin server. Any idea how I can prevent the gzip of the body (a special Accept-Encoding header maybe) or unzip it using something like the gzio library on luaforge (http://luaforge.net/projects/gzio/)?
Hi! I'm actively using a number of your plugins with great results - thank you!!! I'm now running up against some new potential use cases and I'm curious if having the functionality to execute lua code in the later phase handlers would be appropriate. Here's what I'm after:
I perform a number of dynamic redis queries via a pipeline within the access_by_lua handler. This works great! However, I would also like to save information, update Zset scores within redis which does not necessarily need to happen at this layer. I'm curious how much more efficient the entire process would be if I could save info back into redis via a log_by_lua handler that happened late in the nginx phases (like NGX_HTTP_LOG_PHASE) and did not interfere before my other dynamic code fires.
I know this functionality doesn't exist today, but curious if the above is sound logic and whether adding support for more lua_handlers (like log_by_lua*) might be feasible?
Again, big thumbs up for all the contributions to the nginx community thus far :)
Is it possible to make it works with luarocks ?
if yes, how ?
i can require luarocks itself require("luarocks.require")
, but i call another library i installed with luarocks i got some errors.
I would like to pass arbitrary headers to requests made through the location.capture mechanism, but looking at the source it appears that the set_content_length_header method is what handles all of the header duplication from the parent request. Are there any plans to add this functionality?
hi, i just implemented the code to be able to get really ALL request headers which are available via a table. Setting a new request header is available, too.
My problem is, that i was not able to implement it the way you did the other methods ( with __index and __newindex). Somehow either the parameters for getting or for setting were not working
i implemented it with extra functions for now ngx.req_header_set("key", "value") and ngx.req_header_get() (which returns a table)
the changes are here: https://github.com/moodydeath/lua-nginx-module/compare/master...req_header
there is still some work to do (error with no arguments, etc) and i think som request-headers have to be changed otherwise by hard-coded variables in nginx (content-length)
the other thing is, that - even if i tried a lot of things - i am not able to do it the way with __index / __newindex.
Is there a way to access $1, $2 and such from lua?
I tried the obvious ngx.var[1]
and ngx.var["1"]
but they didn't work.
One workaround is to set them to other variables: set $arg1 $1;
but it adds unnecessary clutter.
Hi,
I've been fishing around in the lua code a bit more, and it appears to me that memory allocation in ngx_lua as you currently have it used free() and realloc() for memory allocation, rather than using ngx_free() and ngx_palloc().
Is there a reason for this? Would it not be better to use a function that wrapped around ngx_palloc?
Cheers,
Marcus.
Hi guys,
I believe that recent versions of ngx_lua have the problem that if you pass a table to ngx.print() they segfault. I say believe, because the builds I run have a lot of code that I've been hacking recently, so there may be a bug in that, but I tried back to version 2.0 of ngx_lua and it went away. It may not be for every structure of table (I've not really tried more than one), but it segfaults for at least some.
I've tested in both the latest versions of standard and JIT Lua as of today. The bug appeared some time not long after version 2.1.7 I think - I've not done extensive testing to pin it down to an exact version.
Just thought I'd let you know.
Cheers,
Marcus.
At first: I still don't know, where the error is coming from exactly.
When doing a post-request with data to php-scripts via ngx.location.subrequests the fastcgi processing has a timeout (504 for the client then) like:
2011/06/21 14:19:41 [error] 12165#0: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 10.100.20.192, server: localhost, request: "GET /test.php HTTP/1.1", subrequest: "/test.php", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "10.20.10.216:1337"
There is a Ubuntu 10.04 32bit on a VMware Server, a Ubuntu 11.04 32bit on a VMware Server, a ArchLinux (up-to-date) 32bit on a VMware Server and a ArchLinux (up-to-date) 64bit on my laptop as a local installation.
The machines all have nginx 1.0.4 and the latest lua-nginx-module and ngx_devel_kit (even did a new clone - and no pull)
!!! The weird thing is: The error occurs on all machines, but not on my local ArchLinux. And the ONLY occur when lua-code is active - without everything works normal.
To make it easier i only describe the 32bit (vm) and 64bit (local) ArchLinux machines:
VM:
2.6.39-ARCH i686 GNU/Linux
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
luasocket 2.0.2-5 (from package repository - not luarocks)
gcc version 4.6.0 20110603 (prerelease) (GCC)
Local:
2.6.39-ARCH x86_64 GNU/Linux
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
luasocket 2.0.2-5 (from package repository - not luarocks)
gcc version 4.6.0 20110603 (prerelease) (GCC)
And on both machines i have nginx-1.0.4 and even did compile it with lua-nginx-module and ngx_dev_kit as a new user with fresh cloned repositories (only a few hous ago)
Here's the lua-code
function set_request_method()
local val = ngx.var.request_method
if val == "GET" then
return ngx.HTTP_GET
elseif val == "HEAD" then
return ngx.HTTP_HEAD
elseif val == "PUT" then
return ngx.HTTP_PUT
elseif val == "POST" then
return ngx.HTTP_POST
elseif val == "DELETE" then
return ngx.HTTP_DELETE
end
end
res = ngx.location.capture( or ngx.var.request_uri, { method = set_request_method(), body =
"foo"})
for i,j in pairs(res.header) do
ngx.header[i] = j
end
ngx.status = res.status
ngx.print(res.body)
ngx.exit(res.status)
ngx.flush()
The php-script:
<?php
echo @file_get_contents('php://input');
?>
When i access the php-script on the local Archlinux64bit, it shows "foo" in the client, like expected - when i access it on the VMware Archlinu32bit, i get the 504-timeout and the fcgi-error in the logs :-(
I don't know what could cause this - The machines are theoretically the same! (Besides one is 32bit and one 64bit), all the configuration-files are the same, too.
The Debug-logs when accessing the test.php-script:
The local installation, where everything works: http://pastebin.com/XvE9zKWA
The vmware server, where it fails: http://pastebin.com/9fFhYuUZ
Thanks, moody
It is possible to do like this:
ngx.read_request_body(function (data)
if XXX then
return ngx.OK -- NO more data is require
else
return ngx.AGAIN -- Call me again when more data income
end
end)
The following error happens when building lua-nginx-module with nginx 1.0.5:
../chaoslawful-lua-nginx-module-188cd41/src/ngx_http_lua_script.c: In function ‘ngx_http_lua_compile_complex_value’:
../chaoslawful-lua-nginx-module-188cd41/src/ngx_http_lua_script.c:159:18: error: ‘n’ may be used uninitialized in this function
make[1]: *** [objs/addon/src/ngx_http_lua_script.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/home/hydra35/Downloads/nginx-1.0.5'
make: *** [build] Error 2
Configure parameters:
./configure --add-module=../simpl-ngx_devel_kit-bc97eea --add-module=../chaoslawful-lua-nginx-module-2be9349
System and gcc version:
$ lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 11.04
Release: 11.04
Codename: natty
$ gcc --version
gcc.real (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
I am using the lua nginx module successfully with the standard lua interpreter. I tried it with luajit version 2.0 beta 5, but nginx crashes with a segmentation fault. What information can I provide to help resolve this issue? I'm running it on Snow Leopard Server. I'll try it with other versions of luajit to see if I can narrow down the problem. What versions of luajit have you tested with? Which platforms?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.