Nginx uses the lua script, nginxlua script

Source: Internet
Author: User

Nginx uses the lua script, nginxlua script
This article describes how to use the lua script in nginx. The third-party module lua-nginx-module is used to call the lua script in nginx. A Configuration example is provided.

Lua is a language similar to JavaScript. Ngix_Lua also uses asynchronous single-thread, and its syntax is even simpler than JS. According to previous evaluations, the performance of Ngix_lua is almost Node. JS.

Nginx features

1. Popular High-Performance HTTP servers
2. event-driven (asynchronous) Architecture
3. A small amount of memory can be measured
4. Declarative configuration language
5. C-based scalable modules

You can use lua-nginx-module to start the lua script on nginx.

Example:

location / {    content_by_lua '        local res = ngx.location.capture("/sub")        if res.status >= 500 then             ngx.exit(res.status)         end        ngx.status = res.status        ngx.say(res.body)    ';}location /sub {    echo "Hello, Sub-Request!";}
Lua-nginx-module on Github Project address https://github.com/openresty/lua-nginx-module
Openresty and nginxconf call the lua script. Why is nil always reported when the lua script loads dynamic libraries?

After you install LUA, add the library path to the system variable path.
Generally \ Lua \ 5.1 \ clibs

Download
Lua Rocks provides a simple solution to upgrade and update the Lua extension Library (similar to the yum function in linux)

Nginx calls the lua script, while the lua script calls the functions in the business C program. paste a sample that can be run ~~

I don't know what nginx is.
However, I can help you write a lua call to the c function.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.