本文发布于Cylon的收藏册,转载请著名原文链接~


location = /reqq {
	default_type text/plain;
	content_by_lua_block {
		ngx.req.read_body()
		local data = ngx.req.get_body_data()
                local args, err = ngx.req.get_uri_args()
		if not args then
			ngx.say('post fail')
			return
		end
		
        for key,v in pairs(args) do
			ngx.say(key,"::",v,"--")
		end
		ngx.say(data)
	}
}

ngx.exec 内部重定向

location = /bb {
    default_type text/plain;
    content_by_lua_block{
        ngx.exec('/reqq?m=DaoShengPay3&c=Pay&orderNo=PH201910111')
    }
}

location = /reqq {
    default_type text/plain;
    content_by_lua_block {
       ngx.req.read_body()
       local data = ngx.req.get_body_data()
       local args, err = ngx.req.get_uri_args()
       if not args then
               ngx.say('post fail')
               return
       end
       for key,v in pairs(args) do
               ngx.say(key,"::",v,"--")
       end
       ngx.say(data)
    }
}

1570889980396

ngx.log

location = /testlog {
    default_type text/plain;
    content_by_lua_block{
        ngx.say('hello lua log')
        ngx.log(ngx.ERR, 'print hello lua log')
    }
}
2019/10/12 22:25:31 [error] 468#0: *248 [lua] content_by_lua(nginx.conf:44):3: print hello lua log, client: 203.90.247.72, server: test111.hou2008.com, request: "GET /testlog HTTP/1.1", host: "test111.hou2008.com:8181", referrer: "http://test111.hou2008.com/testlog"

Nginx API for Lua

https://github.com/openresty/lua-nginx-module

https://www.zifangsky.cn/1024.html

本文发布于Cylon的收藏册,转载请著名原文链接~

链接:https://www.oomkill.com/2019/10/lua-nginx-api/

版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」 许可协议进行许可。