Is it possible to host GitLab in a subdirectory of www root, like http://www.mydomain.com/gitlab ?

4,027 views
Skip to first unread message

Jianwen Wei

unread,
May 13, 2012, 11:24:21 AM5/13/12
to gitl...@googlegroups.com
Hi, 

  I've set up a GitLab on my Scientic Linux 6.2 server and it's so awesome. Thank all the guys working for the GitLab project.

  I've got a question: Is it possible to host GitLab in a subdirectory of www root? So that I can get access to gitlab web via http://www.mydomain.com/gitlab/, rather than http://gitlab.mydomain.com/.

  I follow GitLab's official manual, setting up GitLab on gitolite and nginx. Here is nginx's core configuration, which makes GitLab service available at http://gitlab.mydomain.com/.

 server {
  listen 80;
  server_name gitlab.mydomain.com;
  root /home/gitlab/gitlab/public;
 
  # individual nginx logs for this gitlab vhost
  access_log  /var/log/nginx/gitlab_access.log;
  error_log   /var/log/nginx/gitlab_error.log;
 
  location / {
  # serve static files from defined root folder;.
  # @gitlab is a named location for the upstream fallback, see below
  try_files $uri $uri/index.html $uri.html @gitlab;
  }
 
  # if a file, which is not found in the root folder is requested, 
  # then the proxy pass the request to the upsteam (gitlab unicorn)
  location @gitlab {
  proxy_redirect     off;
  # you need to change this to "https", if you set "ssl" directive to "on"
  proxy_set_header   X-FORWARDED_PROTO http;
  proxy_set_header   Host              gitlab.mydomain.com:80;
  proxy_set_header   X-Real-IP         $remote_addr;
 
  proxy_pass http://gitlab;
  }
 
 }

  Assume that my www-root lies in /var/www/html and I make a symbolic link, /var/www/html/gitlab, pointing to /home/gitlab/gitlab/public. I doubt that, whether a mere modification in nginx.conf, which changes "root /home/gitlab/gitlab/public" to "root /var/www/html", will fulfill my need.

  Therefore, I need your advice. Besides changing nginx serving root, is there anything I should do to make http://www.mydomain.com/gitlab/ usable? Thanks!

José Carlos de Campos

unread,
May 13, 2012, 1:36:55 PM5/13/12
to gitl...@googlegroups.com
Hi,

I have the same doubt, anyone can help us?


Thanks ;)
 

José Carlos de Campos

unread,
May 16, 2012, 1:07:38 PM5/16/12
to gitl...@googlegroups.com
Hi,


On Sunday, May 13, 2012 6:36:55 PM UTC+1, José Carlos de Campos wrote:
Hi,


On Sunday, May 13, 2012 4:24:21 PM UTC+1, Jianwen Wei wrote:
Hi, 

  I've set up a GitLab on my Scientic Linux 6.2 server and it's so awesome. Thank all the guys working for the GitLab project.

  I've got a question: Is it possible to host GitLab in a subdirectory of www root? So that I can get access to gitlab web via http://www.mydomain.com/gitlab/, rather than http://gitlab.mydomain.com/.

  I follow GitLab's official manual, setting up GitLab on gitolite and nginx. Here is nginx's core configuration, which makes GitLab service available at http://gitlab.mydomain.com/.

 server {
  listen 80;
  server_name gitlab.mydomain.com;
  root /home/gitlab/gitlab/public;
 
  # individual nginx logs for this gitlab vhost
  access_log  /var/log/nginx/gitlab_access.log;
  error_log   /var/log/nginx/gitlab_error.log;
 

I change the follow line from location / { to something like location /x { , and when I go to mydomain.com/x appears the message "404 Not Found".

Why this happen? How can I change the gitlab default folder to a sub-folder of my domain?

 
  location / {
  # serve static files from defined root folder;.
  # @gitlab is a named location for the upstream fallback, see below
  try_files $uri $uri/index.html $uri.html @gitlab;
  }
 
  # if a file, which is not found in the root folder is requested, 
  # then the proxy pass the request to the upsteam (gitlab unicorn)
  location @gitlab {
  proxy_redirect     off;
  # you need to change this to "https", if you set "ssl" directive to "on"
  proxy_set_header   X-FORWARDED_PROTO http;
  proxy_set_header   Host              gitlab.mydomain.com:80;
  proxy_set_header   X-Real-IP         $remote_addr;
 
  proxy_pass http://gitlab;
  }
 
 }

  Assume that my www-root lies in /var/www/html and I make a symbolic link, /var/www/html/gitlab, pointing to /home/gitlab/gitlab/public. I doubt that, whether a mere modification in nginx.conf, which changes "root /home/gitlab/gitlab/public" to "root /var/www/html", will fulfill my need.

  Therefore, I need your advice. Besides changing nginx serving root, is there anything I should do to make http://www.mydomain.com/gitlab/ usable? Thanks!

I have the same doubt, anyone can help us?


Thanks ;)
 


Cheers ;) 

José Carlos de Campos

unread,
May 18, 2012, 6:05:05 AM5/18/12
to gitl...@googlegroups.com
Hi,

Finally I can resolve this issue.

I remove nginx and install apacha2 to manager the virtualhosts. What I do?

-----

sudo aptitude install apache2
sudo passenger-install-apache2-module

ln -s /home/gitlab/gitlab/public/ /var/www/gitlab

sudo vim /etc/apache2/httpd.conf

LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.12/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.12
PassengerRuby /usr/local/bin/ruby

<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www
<Directory /var/www>
Allow from all
</Directory>

RailsBaseURI /gitlab
<Directory /var/www/gitlab>
Options -MultiViews
</Directory>
</VirtualHost>

sudo /etc/init.d/apache2 restart

-----

And thats it, now at http://localhost I have the normal website, at http://localhost/gitlab I have gitlab instalation.

Cheers ;) 

Jianwen Wei

unread,
May 18, 2012, 10:12:38 AM5/18/12
to gitl...@googlegroups.com
Hmm. It looks good. Nice job, Jose. I will continue to find if there's a nginx approach.

在 2012年5月18日星期五UTC+8下午6时05分05秒,José Carlos de Campos写道:

Luiz Matsumura

unread,
Jun 19, 2012, 8:12:11 PM6/19/12
to gitl...@googlegroups.com

Em sexta-feira, 18 de maio de 2012 11h12min38s UTC-3, Jianwen Wei escreveu:
Hmm. It looks good. Nice job, Jose. I will continue to find if there's a nginx approach.


From the phusion passenger developers blog:
 

Markus

unread,
Oct 24, 2012, 5:17:01 PM10/24/12
to gitl...@googlegroups.com
Hi,

while looking for a solution I came accross this post:

https://groups.google.com/d/msg/gitlabhq/mPcpq85VHew/4qupsUY90oEJ

Works for me but you have to edit gitlab/config.ru.

Cheers
Reply all
Reply to author
Forward
0 new messages