Rewrite equivalent of a simple redirect in HAProxy

haproxy

I currently have a line in our HAProxy config that I uncomment when I want to put the site into 'maintenance mode'. It just redirects requests not for the static subdomain to a maintenance page.

redirect location http://static.site.com/maintenance.htm unless { hdr(host) -i static.site.com }

Of course, this is is a 30x type redirect, so a new http request, and the user sees the url change.

I'd prefer to simply rewrite the request to another url (so the original url does not change in the browser), but can't work out how to do this. I've tried experimenting with reqirep, but perhaps my regex-fu is not up to scratch.

Can anyone suggest a solution? Thanks

Best Answer

The following rule should suffice:

reqirep ^.* http://static.site.com/maintenance.htm

Reference