Hi, I wrote a kong plugin that does a simple URI rewrite. The function is executed in the access_by_lua context.
THe code is simple.
It does
function CustomHandler:access(config)
-- Eventually, execute the parent implementation
-- (will log that your plugin is entering this context)
CustomHandler.super.access(self)
-- Implement any custom logic here
local headers = ngx.req.get_headers(10)
print ("Old URI " .. ngx.var.uri) //PRINTS hello.html
print ("Setting URI to main.html")
ngx.req.set_uri("main.html") //PRINTS main.html
print ("Old URI 2" .. ngx.var.uri)
ngx.req.set_uri_args("a=3")
end
At the backend nginx server, the URI continues to be hello.html. However, It has now added the URI args
172.18.0.1 - - [08/Aug/2016:17:44:00 +0000] "GET /hello.html?a=3 HTTP/1.0" 404 571 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36" "10.199.61.202"
It appears that the set_uri function has no effect on the actual request sent. What am i doing wrong? What should i be doing to set the URI?
Thanks