How to Use the Lua script in nginx

Source: Internet
Author: User
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

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.