2

Can I configure haproxy to redirect a url ending in /video1?autoplay=1 to a different url but keeping the querystring value?

e.g

http://domain.com/video1?autoplay=1

needs to redirect to

http://newdomain/video/1?autoplay=1

I can do the acl to match the /video1 but cannot work out how to throw away everything to the left of the querystring

Thanks in advance

0

3 Answers 3

1

You can redirect and preserve the query string:

  acl path_video1 path /video1
  http-request redirect location /video/1?%[query] if path_video1

If you want any number to work (eg, /video234) it's only a bit more complex:

  acl path_video path_reg ^/video[\d+]
  http-request redirect location %[path,regsub(/video,/video/,)]%[query] if path_video

This matches the number part using a regular expression, then simply replaces /video with /video/, and preserves the query string.

0

I don't think HAproxy's current version has support for this kind of redirection. Does it really need to be HAproxy? Maybe you can also use Apache on the localhost and make it listen to say, port 81, and do the redirection but keep the query string through mod_rewrite. This will, of course, add an overhead, though.

0

Could you explain what it would be useful for ? It might be easy to implement in haproxy and could even be done before dev16 in a few days, but before adding features I need to be convinced about their use.

5
  • I single use case: website moved (from one domain to other)
    – jrumbinas
    Apr 6, 2013 at 15:35
  • no, look, the request is changed, not only the domain. Apr 24, 2013 at 6:52
  • Oops, I haven't noticed it... How about redirect keeping the same query string?
    – jrumbinas
    Apr 24, 2013 at 13:16
  • @WillyTarreau we are running into it being needed because we moved not only domains but backends as well so the new url schema is different and keeping old Google results going to the right place is important. Sep 29, 2015 at 19:39
  • Then take a look at either haproxy 1.6 (with care) or HAPEE which include a lot more possibilities to manipulate parts of the URL individually and reuse other parts there. Now I think it should be quite possible. Oct 21, 2015 at 20:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .