I ended up trying out the new Lua functionality in 1.6 and was able to get this
to work with it.
haproxy.cfg
global
lua-load /path/query.lua
frontend FE-HTTP
bind 127.0.0.1:80
mode http
http-request lua query
query.lua
function query(txn)
local mydate = txn.sc:http_date(txn.f:date())
local sid = txn.f:url_param("sid")
local sid_guid = txn.f:url_param("sid_guid")
local strid = txn.f:url_param("strid")
local response = ""
response = response .. "HTTP/1.1 301 Moved Permanently\n"
response = response .. "Content-Type: text/html; charset=iso-8859-1\n"
response = response .. "Date: " .. mydate .. "\n"
response = response .. "Location: " .. "http://shop.companyx.com/shop.aspx?" .. "sid=" .. sid .. "&sid_guid=" ..
sid_guid .. "&strid=" .. strid .. "&shopurl=search.aspx" .. "\n"
response = response .. "Content-Length: " .. buffer:len() .. "\n"
response = response .. "Connection: close\n"
response = response .. "\n"
txn.res:send(response)
txn:close()
end
I'm just curious if this is the right way to do this in HAProxy?
On May 07, 2015, at 10:56 AM, Patrick Slattery <[email protected]> wrote:
Hi, I'm trying to figure out how rewrite an incoming query string such as:
http://www.example.com/?domain=companyx.com&sdn=&sid=123456789&sid_guid=d8bfbc1a-c790-4cf8-beec-ffbbf72d9476&k=mystring&strid=1e961&1e961&t=%20?
becomes:
http://shop.companyx.com/shop.aspx?sid=123456789&sid_guid=d8bfbc1a-c790-4cf8-beec-ffbbf72d9476&strid=1e961&shopurl=search.aspx
I can see how to extract each of the query params with urlp(parmname) but I
don't see any obvious way of reassembling the query string from the extracted
variables.
Is this practical in HAProxy (any version) or should I look at using some other
tool for this?
Thanks.