title: Apache reverse proxy to gitlab hosted on another server
body: <p>I'm trying for the past months to use Apache as a reverse proxy but I can't manage to configure it the way I want.</p>
  
  <p><strong><em>Network configuration</em></strong></p>
  
  <p>In my local network, all incoming HTTP requests are routed by my firewall to an Apache server (running on <strong>Debian</strong>). This Apache server hosts 3 different Web services. </p>
  
  <p>A fourth web service, <strong>Gitlab</strong>, is hosted on a second server (<strong>Ubuntu</strong>) and runs in a docker. Gitlab is referenced by my internal DNS as <code>gitlab/</code>. So, I can access it in my browser from the URL <code>http://gitlab/</code>. </p>
  
  <p><strong><em>Desired Apache behavior</em></strong></p>
  
  <p>I would like to access to these 4 different web services from the Internet by typing in my browser :</p>
  
  <pre><code>http://ip_address/web_service_1/
  http://ip_address/web_service_2/
  http://ip_address/web_service_3/
  http://ip_address/gitlab/
  </code></pre>
  
  <p>Web_service_1 to web_service_3 work perfectly. But I can't figure how to configure Apache as a proxy to Gitlab.</p>
  
  <p>From the Internet, a request to Gitlab should go through the firewall, be routed to the <strong>Debian</strong> server running Apache and finally to the <strong>Ubuntu</strong> server running Gitlab.</p>
  
  <p>Unfortunately, when I send a request to <code>http://ip_address/gitlab</code>, I receive <code>http://ip_address/users/sign_in</code> instead of <code>http://ip_address/gitlab/users/sign_in</code> and Apache cannot route next requests to Gitlab be cause the <code>/gitlab/</code> part disappeared.</p>
  
  <p><strong><em>Apache configuration</em></strong></p>
  
  <p>To get the results explained above, I've created a file named <code>/etc/apache2/sites-available/proxy.conf</code> on the Debian server which contains :</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
     ServerName myProxy
     RewriteEngine On
     RewriteRule ^/web_service_1(.*) http://debian_server/web_service_1/$1
     RewriteRule ^/web_service_2(.*) http://debian_server/web_service_2/$1
     RewriteRule ^/web_service_3(.*) http://debian_server/web_service_3/$1
     ProxyPass /gitlab http://gitlab/
     ProxyPassReverse /gitlab http://gitlab/
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>As you know, this doesn't work as expected : the <code>/gitlab/</code> part disappears from the URL.</p>
  
  <p>After a lot of researches and tests, I found a tutorial which brought me a better result ... not working either. My <code>proxy.conf</code> is now :</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;  
      ServerName myProxy 
      ServerAlias myProxy
      DocumentRoot /var/www/html
      RewriteEngine On
      LogLevel error trace6
      RewriteRule ^/web_service_1(.*) http://127.0.2.1/web_service_1/$1 [P]
      RewriteRule ^/web_service_2(.*) http://127.0.2.2/web_service_2/$1 [P]   
      RewriteRule ^/web_service_3(.*) http://127.0.2.3/web_service_3/$1 [P]   
      ProxyRequests Off
  
      ProxyPass /gitlab/ http://gitlab/
  
      ProxyHTMLURLMap http://gitlab /gitlab
  
      &lt;Location /gitlab/&gt;
          ProxyPassReverse /
          ProxyHTMLEnable On
          ProxyHTMLURLMap / /gitlab/
          RequestHeader unset Accept-Encoding
      &lt;/Location&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>With this solution, I almost get the sign in page, but some elements are missing and I can't log in. Maybe I forgot some option in the proxy configuration ...</p>
  
  <p>Does anyone know how to improve this solution and make it works ?</p>
  
  <p>Thanks a lot for your help.</p>