2
votes

I have successfully installed Gitlab on Ubuntu 14.04 using https://about.gitlab.com/downloads/#ubuntu1404 but I am struggling to make redirect and access it through web (https://my.example.com/gitlab).

I have modified /etc/gitlab/gitlab.rbto:

external_url 'https://my.example.com/gitlab'

nginx['enable'] = false

And reconfigured with sudo gitlab-ctl reconfigure

If I uncomment:

web_server['external_users'] = ['www-data']

I get:

Recipe Compile Error in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab-ee/recipes/default

NoMethodError ------------- undefined method `-' for nil:NilClass

Cookbook Trace: --------------- /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/config.rb:21:in from_file'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb:26:in
from_file'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab-ee/recipes/default.rb:18:in `from_file'

Relevant File Content: ---------------------- /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/config.rb:

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>>
Gitlab.from_file('/etc/gitlab/gitlab.rb') 22: end 23: 24: node.consume_attributes(Gitlab.generate_config(node['fqdn'])) 25:

I have tried adding various gitlab.conf to /etc/apache2/sites-available/ but https://my.example.com/gitlab does not redirect to Gitlab login page, I get 'Page not found' from Redmine service which runs on home page. Current default-ssl.conf uses DocumentRoot /var/www while Gitlab DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public. Apache2 is configured to use SSL.

UPDATE 1

I have made symlink:

sudo ln -s /opt/gitlab/embedded/service/gitlab-rails/public /var/www/gitlab

So now it can be configured in default-ssl.conf.

Alias /gitlab "/var/www/gitlab"

Does not forward to Gitlab homepage, while

Alias /gitlab "/var/www/gitlab/deploy.html"

works well. What is Gitlab home page directory? Where is index.html file?

UPDATE 2

If I add

RackBaseURI /gitlab
RailsBaseURI /gitlab
<Directory /var/www/gitlab>
    Allow from all
    Options -MultiViews
</Directory>

I get error after entering https://my.example.com/gitlab/

Web application could not be started

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:

bundle install

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:

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.

-------- The exception is as follows: ------- Could not find rake-10.5.0 in any of the sources (Bundler::GemNotFound)

/var/lib/gems/1.9.1/gems/bundler-1.12.5/lib/bundler/spec_set.rb:95:in block in materialize' /var/lib/gems/1.9.1/gems/bundler-1.12.5/lib/bundler/spec_set.rb:88:inmap!' /var/lib/gems/1.9.1/gems/bundler-1.12.5/lib/bundler/spec_set.rb:88:in materialize' /var/lib/gems/1.9.1/gems/bundler-1.12.5/lib/bundler/definition.rb:140:inspecs' /var/lib/gems/1.9.1/gems/bundler-1.12.5/lib/bundler/definition.rb:185:in specs_for' /var/lib/gems/1.9.1/gems/bundler-1.12.5/lib/bundler/definition.rb:174:inrequested_specs'

The exception above was solved after updating Ruby.

UPDATE 3

Now I get

enter image description here

with

Alias /gitlab "/var/www/gitlab"
AllowEncodedSlashes NoDecode

<Directory /var/www/gitlab>
        Options Indexes FollowSymLinks MultiViews
        PassengerAppRoot "/var/www/gitlab"
        RailsBaseURI /var/www/gitlab
        AllowOverride None
        Order allow,deny
        allow from all
</Directory>

How to configure Gitlab and Apache2 to get Gitlab first page when entering https://my.example.com/gitlab?

2

2 Answers

2
votes

It sounds like your Apache configuration is not proxying to the GitLab server on port 8080 (unicorn). There are example Apache configuration files available at https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/web-server/apache.

There's also a good post explaining the steps to use Apache with GitLab Omnibus at http://ryansechrest.com/2015/08/use-apache-instead-of-built-in-nginx-in-gitlab-ce/. It's a little over a year old, so the Apache configuration may be a little outdated. Use the guide, but substitute the Apache configuration from the gitlab-recipes link above and it should work.

2
votes

I had other service working on 8080 so I have changed Unicorn port to 9099. Modified Gitlab configuration sudo nano /etc/gitlab/gitlab.rb:

external_url 'https://subdomain.example.com/gitlab'

web_server['username'] = 'apache' #'gitlab-www'
web_server['group'] = 'apache' #'gitlab-www'

nginx['enable'] = false

unicorn['listen'] = '127.0.0.1'
unicorn['port'] = 9099

Reconfigured Gitlab: sudo gitlab-ctl reconfigure

Modified Apache configuration sudo nano /etc/apache2/apache2.conf with adding:

ProxyPass         /gitlab http://127.0.0.1:9099/gitlab
ProxyPassReverse  /gitlab http://127.0.0.1:9099/gitlab
RequestHeader add X-Forwarded-Proto https

Reloaded it:

sudo service apache2 reload