Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
haproxy, remove /app after selecting backend
Code to change a request from / to /app1/
reqirep ^([^\ :]*)\ /(.*) \1\ /app1/\2
If urls in the response contain absolute urls it might be required to use this:
acl no_redir url_beg /app1/
reqirep ^([^\ :]*)\ /(.*) \1\ /app1/\2 if !no_redir
The code makes sure that the method and url-path behind the / stays the same. Which method you need exactly might depend on the application thats running.
For readability of the above how change a request from /app1/ to /app1/app1redir/
reqirep ^([^\ :]*)\ /app1/(.*) \1\ /app1/app1redir/\2
If those above dont work you might still be able to get a acceptable workaround by using a redirect:
acl no_redir url_beg /app1/
http-request redirect location http://%[req.hdr(Host)]/app1/ if !no_redir

This comment has been minimized.

Copy link

@dalenoe dalenoe commented May 15, 2019

What version(s) of haproxy will this work with?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment