ReverseProxy from apache2 to GitLab fails for login URL and after login (otherwise ok)

Dear all,

I have a similar problem as the one described in http://forum.gitlab.com/t/gitlab-and-nginx-as-a-reverse-proxy/4617: My apache2 reverse proxy https://www.example.com/gitlab/ redirects to https://www.example.com/users/sign_in instead of https://www.example.com/gitlab/users/sign_in. Browsing directly to https://www.example.com/gitlab/users/sign_in works fine for the login, but then I’m again automatically redirected to https://www.example.com/ (which of course fails). If I then add the “/gitlab/” part manually everything works from then on and all links are correct.

My apache2 proxy configuration for this is:

<Location /gitlab>
  ProxyHTMLEnable on
  ProxyHTMLExtended on

  ProxyHTMLLinks  a          href
  ProxyHTMLLinks  area       href
  ProxyHTMLLinks  link       href
  ProxyHTMLLinks  img        src longdesc usemap
  ProxyHTMLLinks  object     classid codebase data usemap
  ProxyHTMLLinks  q          cite
  ProxyHTMLLinks  blockquote cite
  ProxyHTMLLinks  ins        cite
  ProxyHTMLLinks  del        cite
  ProxyHTMLLinks  form       action
  ProxyHTMLLinks  input      src usemap
  ProxyHTMLLinks  head       profile
  ProxyHTMLLinks  base       href
  ProxyHTMLLinks  script     src for

  ProxyHTMLURLMap https://our.gitlab.server/ /gitlab/
  ProxyHTMLURLMap /                          /gitlab/

  ProxyPass          https://our.gitlab.server/
  ProxyPassReverse   https://our.gitlab.server/
</Location>

I know, that using the same “prefix” /gitlab/ also on the GitLab server side would work, but this is what we explicitely don’t want. For me it looks as if all headers and link rewritings work fine with the exception of the first redirection and the redirection directly after login. How can I fix these two redirections, so that they are rewritten correctly, too?

Apache version is 2.4, GitLab is version 8.17.0.