There is a param named "RedirectURL" in http request header. I want to remove it in ngx_lua and then send this request to RedirectURL, here is some snippet in 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;
}
When I test it use
curl --header "RedirectURL:www.google.com" xx.xx.xx.xx:xx/apiproxytest
I get result:
1: www.google.com
2: www.google.com
I don't know where the wrong is. Who can help me figure it out? Thanks for any help!
ngx.req.clear_header
location /apiproxytest {
set_by_lua $redirectURL '
local url = ngx.req.get_headers()["RedirectURL"]
ngx.req.clear_header("RedirectURL")
return url
';
proxy_pass $redirectURL;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With