[Lua] "Hello, world!" from Lua file?

Shohreh nginx-forum at nginx.us
Tue Jan 28 11:51:58 UTC 2014

Yichun Zhang (agentzh) Wrote:
> Alternatively one can set the Content-Type response header directly in Lua
(which is more flexible):
>     content_by_lua '
>         ngx.header["Content-Type"] = "text/plain"
>         ngx.say("hello world")
>     ';

Thanks for the tip, it works. Is there a tutorial besides the following page
about how to write Lua scripts through ngx_lua?

One other thing: I'd like / to map to index.html which contains a form, and
the Lua script should be called as the action to handle the form. How can I
do this?

This calls the script any time I hit the root directory:

location / {
    root   html;
    index  index.html index.htm;
    content_by_lua_file html/hello.lua;
    #add_header Content-Type text/plain;

Thank you.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,246864,246907#msg-246907

More information about the nginx mailing list