- Edited
hi, 大佬们好, 我在做一个前端反向代理工具, 遇到一个不理解的报错
location / {
lua_need_request_body on;
set $upp '';
set $cookie_domain $host;
content_by_lua_file conf/lua/proxy.lua;
log_by_lua_block {
local log = require "log";
log[ngx.ctx.uid].sent = true;
}
}
location /proxy {
internal;
proxy_cookie_domain ~.*$ $cookie_domain;
proxy_cookie_path ~.*$ /;
proxy_set_header 'Access-Control-Allow-Origin' '*';
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass $upp;
}
这是我的 lua 代码
local res = ngx.location.capture("/proxy", {
share_all_vars = true
});
for k, v in pairs(res.header) do
ngx.header[k] = v;
end
ngx.status = res.status;
ngx.print(res.body)
原因应该是 ngx.location.capture
的请求升级为 websocket 了, 有什么办法能避免这个报错吗