http 请求标头中有一个名为“RedirectURL”的参数。我想在 ngx_lua 中删除它,然后将此请求发送到 RedirectURL,这是 nginx.conf 中的一些片段
location /apiproxytest {
set_by_lua $redirectURL '
return ngx.req.get_headers()["RedirectURL"]
';
header_filter_by_lua '
ngx.header["RedirectURL"] = nil;
';
echo "1:" $redirectURL;
set_by_lua $redirectURL2 '
return ngx.req.get_headers()["RedirectURL"]
';
echo "2:" $redirectURL2;
proxy_pass $redirectURL;
}
当我测试它使用
curl --header "RedirectURL:www.google.com" xx.xx.xx.xx:xx/apiproxytest
我得到结果:
1: www.google.com
2: www.google.com
我不知道错在哪里。谁能帮我弄清楚?谢谢你的帮助!