title: Gitlab on Apache2 with SSL
body: <p>I have successfully installed Gitlab on Ubuntu 14.04 using <a href="https://about.gitlab.com/downloads/#ubuntu1404" rel="nofollow noreferrer">https://about.gitlab.com/downloads/#ubuntu1404</a> but I am struggling to make redirect and access it through web (<a href="https://my.example.com/gitlab" rel="nofollow noreferrer">https://my.example.com/gitlab</a>). </p>
  
  <p>I have modified <code>/etc/gitlab/gitlab.rb</code>to:</p>
  
  <blockquote>
    <p>external_url '<a href="https://my.example.com/gitlab" rel="nofollow noreferrer">https://my.example.com/gitlab</a>'</p>
    
    <p>nginx['enable'] = false</p>
  </blockquote>
  
  <p>And reconfigured with <code>sudo gitlab-ctl reconfigure</code></p>
  
  <p>If I uncomment:</p>
  
  <blockquote>
    <p>web_server['external_users'] = ['www-data']</p>
  </blockquote>
  
  <p>I get:</p>
  
  <blockquote>
    <p>Recipe Compile Error in
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab-ee/recipes/default</p>
    
    <p>NoMethodError
    ------------- undefined method `-' for nil:NilClass</p>
    
    <p>Cookbook Trace:
    ---------------   /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/config.rb:21:in
    <code>from_file'<br>
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb:26:in
    </code>from_file'<br>
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab-ee/recipes/default.rb:18:in
    `from_file'</p>
    
    <p>Relevant File Content:
    ---------------------- /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/config.rb:</p>
    
    <p>14:  # See the License for the specific language governing
    permissions and  15:  # limitations under the License.  16:  #  17: 
    18:  Gitlab[:node] = node  19:  20:  if
    File.exists?('/etc/gitlab/gitlab.rb')  21>><br>
    Gitlab.from_file('/etc/gitlab/gitlab.rb')  22:  end  23:  24: 
    node.consume_attributes(Gitlab.generate_config(node['fqdn']))  25:</p>
  </blockquote>
  
  <p>I have tried adding various gitlab.conf to <code>/etc/apache2/sites-available/</code> but <a href="https://my.example.com/gitlab" rel="nofollow noreferrer">https://my.example.com/gitlab</a> does not redirect to Gitlab login page, I get 'Page not found' from Redmine service which runs on home page. Current <code>default-ssl.conf</code> uses <code>DocumentRoot /var/www</code> while Gitlab <code>DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public</code>. Apache2 is configured to use SSL. </p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>I have made symlink:</p>
  
  <pre><code>sudo ln -s /opt/gitlab/embedded/service/gitlab-rails/public /var/www/gitlab
  </code></pre>
  
  <p>So now it can be configured in default-ssl.conf.</p>
  
  <pre><code>Alias /gitlab "/var/www/gitlab"
  </code></pre>
  
  <p>Does not forward to Gitlab homepage, while</p>
  
  <pre><code>Alias /gitlab "/var/www/gitlab/deploy.html"
  </code></pre>
  
  <p>works well. What is Gitlab home page directory? Where is index.html file?</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>If I add </p>
  
  <pre><code>RackBaseURI /gitlab
  RailsBaseURI /gitlab
  &lt;Directory /var/www/gitlab&gt;
      Allow from all
      Options -MultiViews
  &lt;/Directory&gt;
  </code></pre>
  
  <p>I get error after entering <a href="https://my.example.com/gitlab/" rel="nofollow noreferrer">https://my.example.com/gitlab/</a></p>
  
  <blockquote>
    <p>Web application could not be started</p>
    
    <p>It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run:</p>
    
    <p>bundle install</p>
    
    <p>If that didn't work, then the problem is probably caused by your application > being run under a different environment than it's supposed to. Please check > the following:</p>
  
  <pre><code>Is this app supposed to be run as the www-data user?
  Is this app being run on the correct Ruby interpreter? Below you will see which Ruby interpreter Phusion Passenger attempted to use.
  </code></pre>
    
    <p>-------- The exception is as follows: -------
    Could not find rake-10.5.0 in any of the sources (Bundler::GemNotFound)</p>
    
    <p>/var/lib/gems/1.9.1/gems/bundler-1.12.5/lib/bundler/spec_set.rb:95:in <code>block in materialize'
      /var/lib/gems/1.9.1/gems/bundler-1.12.5/lib/bundler/spec_set.rb:88:in</code>map!'
      /var/lib/gems/1.9.1/gems/bundler-1.12.5/lib/bundler/spec_set.rb:88:in <code>materialize'
      /var/lib/gems/1.9.1/gems/bundler-1.12.5/lib/bundler/definition.rb:140:in</code>specs'
      /var/lib/gems/1.9.1/gems/bundler-1.12.5/lib/bundler/definition.rb:185:in <code>specs_for'
      /var/lib/gems/1.9.1/gems/bundler-1.12.5/lib/bundler/definition.rb:174:in</code>requested_specs'</p>
  </blockquote>
  
  <p>The exception above was solved after updating Ruby. </p>
  
  <p><strong>UPDATE 3</strong></p>
  
  <p>Now I get</p>
  
  <p><a href="https://i.stack.imgur.com/5R5NH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5R5NH.png" alt="enter image description here"></a></p>
  
  <p>with </p>
  
  <pre><code>Alias /gitlab "/var/www/gitlab"
  AllowEncodedSlashes NoDecode
  
  &lt;Directory /var/www/gitlab&gt;
          Options Indexes FollowSymLinks MultiViews
          PassengerAppRoot "/var/www/gitlab"
          RailsBaseURI /var/www/gitlab
          AllowOverride None
          Order allow,deny
          allow from all
  &lt;/Directory&gt;
  </code></pre>
  
  <p>How to configure Gitlab and Apache2 to get Gitlab first page when entering <a href="https://my.example.com/gitlab" rel="nofollow noreferrer">https://my.example.com/gitlab</a>? </p>