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

Yichun Zhang (agentzh) agentzh at gmail.com
Mon Jan 27 20:34:43 UTC 2014


Hello!

On Mon, Jan 27, 2014 at 6:00 AM, Jader H. Silva wrote:
>
> You need to set the content-type to this location. e.g.:
>
> add_header Content-Type text/plain;
>

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")
    ';

or use the default_type directive:

    default_type text/plain;
    content_by_lua '
        ngx.say("hello world")
    ';

Regards,
-agentzh



More information about the nginx mailing list