lua_add_variable $proxy;
server {
listen 18883;
proxy_connect_timeout 1s;
preread_by_lua_block {
local sock = ngx.req.socket(true)
local data, err, partial = sock:receive(6)
if not data then
ngx.say("failed to read a line: ", err)
return
end
local r = string.sub(data, 7, len)
ngx.log(ngx.INFO, "prefix is: ", data)
ngx.log(ngx.INFO, "r is: ", r)
ngx.var.proxy= "mq1883"
}
proxy_pass $proxy;
}