我的lua设置如下:
56 location /news {
57 #lua_need_request_body on;
58 rewrite_by_lua '
59 request_method=ngx.req.get_method();
60 if request_method == "POST" then
61 ngx.req.read_body();
62 args = ngx.req.get_post_args();
63 ngx.req.set_uri_args(args);
64 local uri = ngx.re.sub(ngx.var.uri,"^(.*)$","http://abc.com");
65 ngx.req.set_uri(uri);
66 end
67 ';
74 }
我希望当我访问localhost/news 命中这个location时,带参数跳转到http://abc.com。
可是现在跳转,它会在我的链接http://abc.com 前面带上了路径/home/xxx/nginx/html,跳转链接变成了:/home/xxx/nginx/htmlhttp://abc.com。
请问有没有什么办法,可以在使用rewrite_by_lua 时,指定特定的URL?
另外,我知道proxy_pass可以做到,可是由于一些原因,我不能使用proxy_pass。而nginx本身的rewrite也是可以指定特定的URL的,但是这里我希望它跳转的时候带上POST的参数,而nginx的rewrite又做不到这点。
所以,求助!!!!