haproxy forward uri to root of another server

Solution 1:

To get rid of leading parts of the URI, try

reqrep ^(GET|POST)\ /gitlab/(.*) \1\ /\2

i.e., extract the HTTP method into \1 and the path following the gitlab root into \2, then catenate them to a full request.

Note that this may not cut it for many applications, because the appserver doesn't know that clients are supposed to request everything from inside a virtual gitlab/ root directory. Therefor, redirects will apparently "strip" the important root directory.

Such scenarios are solved more easily e.g. with nginx and its mod_proxy or even Apache.