Methods for using LUA scripts in Nginx _nginx

Source: Internet
Author: User
Tags lua

Lua is a language very much like JavaScript, Ngix_lua also uses asynchronous single-threaded, syntax is even simpler than JS, before the evaluation that Ngix_lua performance is almost one times the node.js.

Nginx Features

1. The popular high-performance HTTP server
2. Event-driven (asynchronous) architecture
3. Small and measurable memory footprint
4. Declarative configuration language
5. Scalable modules based on C

You can start the Lua script on Nginx by Lua-nginx-module.

An example:

Copy Code code as follows:

Location/{
Content_by_lua '
Local res = ngx.location.capture ("/sub")
If Res.status >= Then
Ngx.exit (Res.status)
End
Ngx.status = Res.status
Ngx.say (Res.body)
';
}
location/sub {
echo "Hello, sub-request!";
}

Lua-nginx-module the project address on the GitHub https://github.com/openresty/lua-nginx-module

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.