Toggle navigation
Home
安装部署
Archives
Tags
Nginx Lua
2019-10-18 02:58:50
61
0
0
louyj
https://github.com/openresty/lua-nginx-module https://github.com/ledgetech/lua-resty-http #Typical Uses - Mashup'ing and processing outputs of various Nginx upstream outputs (proxy, drizzle, postgres, redis, memcached, and etc) in Lua, - doing arbitrarily complex access control and security checks in Lua before requests actually reach the upstream backends, - manipulating response headers in an arbitrary way (by Lua) - fetching backend information from external storage backends (like redis, memcached, mysql, postgresql) and use that information - to choose which upstream backend to access on-the-fly, - coding up arbitrarily complex web applications in a content handler using synchronous but still non-blocking access to the - database backends and other storage, - doing very complex URL dispatch in Lua at rewrite phase, - using Lua to implement advanced caching mechanism for Nginx's subrequests and arbitrary locations. The possibilities are unlimited as the module allows bringing together various elements within Nginx as well as exposing the power of the Lua language to the user. The module provides the full flexibility of scripting while offering performance levels comparable with native C language programs both in terms of CPU time as well as memory footprint thanks to LuaJIT 2.x. #Installation Note that Nginx, LuaJIT, and OpenSSL official releases have various limitations and long standing bugs that can cause some of this module's features to be disabled, not work properly, or run slower. Official OpenResty releases are recommended because they bundle OpenResty's optimized LuaJIT 2.1 fork and Nginx/OpenSSL patches. Alternatively, ngx_lua can be manually compiled into Nginx: - LuaJIT can be downloaded from the latest release of OpenResty's LuaJIT fork. The official LuaJIT 2.x releases are also - supported, although performance will be significantly lower for reasons elaborated above - Download the latest version of the ngx_devel_kit (NDK) module HERE - Download the latest version of ngx_lua HERE - Download the latest supported version of Nginx HERE (See Nginx Compatibility) install LuaJIT ``` wget https://github.com/openresty/luajit2/archive/v2.1-20190912.zip make make install ##/usr/local/include/luajit-2.1, /usr/local/lib ``` install ngx_devel_kit ``` wget https://github.com/simplresty/ngx_devel_kit/archive/v0.3.1.zip ``` install ngx_lua ``` wget https://github.com/openresty/lua-nginx-module/archive/v0.10.15.zip ``` install openresty ``` https://openresty.org/download/openresty-1.15.8.2.tar.gz tar zxvf openresty-1.15.8.2.tar.gz cd openresty-1.15.8.2 ./configure --prefix=/opt/openresty make && make install ``` Build the source with this module: ``` wget 'https://nginx.org/download/nginx-1.13.6.tar.gz' tar -xzvf nginx-1.13.6.tar.gz cd nginx-1.13.6/ # tell nginx's build system where to find LuaJIT 2.0: #export LUAJIT_LIB=/path/to/luajit/lib #export LUAJIT_INC=/path/to/luajit/include/luajit-2.0 # tell nginx's build system where to find LuaJIT 2.1: export LUAJIT_LIB=/usr/local/lib export LUAJIT_INC=/usr/local/include/luajit-2.1 # Here we assume Nginx is to be installed under /opt/nginx/. ./configure --prefix=/opt/nginx-1.13.6 \ --with-ld-opt="-Wl,-rpath,${LUAJIT_LIB}" \ --add-module=/root/ngx_devel_kit-0.3.1 \ --add-module=/root/lua-nginx-module-0.10.15 \ --with-http_ssl_module --with-http_sub_module --with-http_gunzip_module --with-http_v2_module --with-http_auth_request_module # Note that you may also want to add `./configure` options which are used in your # current nginx build. # You can get usually those options using command nginx -V # you can change the parallism number 2 below to fit the number of spare CPU cores in your # machine. make -j2 make install ``` #Usage import package ``` lua_package_path "/opt/openresty/lualib/?.lua;;"; lua_package_cpath '/opt/openresty/lualib/?.so;;'; ```
Pre:
Kubeless Deployment
Next:
PostgreSQL 10 - pgpool II
0
likes
61
Weibo
Wechat
Tencent Weibo
QQ Zone
RenRen
Submit
Sign in
to leave a comment.
No Leanote account?
Sign up now.
0
comments
More...
Table of content
No Leanote account? Sign up now.