Last active
June 22, 2022 02:25
-
-
Save PiBa-NL/8ad6c222354cbd7a5af5 to your computer and use it in GitHub Desktop.
haproxy, remove /app after selecting backend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Anything less than 2.1, because
reqirep
is deprecated in 2.1 onward