Skip to content

Commit

Permalink
Fix multiple query parameter issue for dynamic backends (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsong93 authored and mhamann committed Jan 3, 2018
1 parent f2c9665 commit c0294da
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions scripts/lua/policies/backendRouting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ function _M.setDynamicRoute(obj)
end
if utils.tableContains(whitelist, u.host) then
ngx.req.set_uri(getUriPath(u.path))
local query = ngx.req.get_uri_args()
for k, v in pairs(u.query) do
query[k] = v
-- Split the dynamicBackend url to get the query parameters in the exact order that it was passed in.
-- Don't use u.query here because it returns the parameters in an unordered lua table.
local split = {string.match(dynamicBackend, '([^?]*)?(.*)')}
local qs = split[2]
if qs ~= nil then
ngx.req.set_uri_args(qs)
end
ngx.req.set_uri_args(query)
setUpstream(u)
else
request.err(403, 'Dynamic backend host not part of whitelist.')
Expand Down

0 comments on commit c0294da

Please sign in to comment.