在nginx.conf中添加如下URL
get_random_string.lua
结果
要说明的:
ngx.HTTP_BAD_REQUEST的参数在ngx_lua中有常量的定义,因此这里可以这样写
ngx_lua 官方文档 https://github.com/openresty/lua-nginx-module/blob/master/README.markdown
目前官方自带模块
- lua-resty-memcached
- lua-resty-mysql
- lua-resty-redis
- lua-resty-dns
- lua-resty-upload
- lua-resty-websocket
- lua-resty-lock
- lua-resty-logger-socket
- lua-resty-lrucache
- lua-resty-string
- ngx_memc
- ngx_postgres
- ngx_redis2
- ngx_redis
- ngx_proxy
- ngx_fastcgi
尽量调用ngx_lua的API,因为是异步非阻塞的
不要调用Lua的API,它是阻塞的