upstream serverA {
server 1.1.1.1:5432;
}
upstream serverB {
server 1.1.1.1:5431;
}
lua_add_variable $proxy;
server {
listen 5430;
preread_by_lua_block{
local sock = ngx.req.socket()
local data = sock:peek(4)
ngx.log(ngx.ERR,data)
}
本机测试 telnet 127.0.0.1 5430 错误日志报错
2021/02/22 02:54:41 [error] 7369#0: *23 stream [lua] preread_by_lua(nginx.conf:411):4: while prereading client data, client: 127.0.0.1, server: 0.0.0.0:5430
2021/02/22 02:54:41 [error] 7369#0: *23 no host in upstream "", client: 127.0.0.1, server: 0.0.0.0:5430, bytes from/to client:0/0, bytes from/to upstream:0/0