I installed Gitlab CE on a dedicated Ubuntu 14.04 server edition with Omnibus package.
Now I would want to install three other virtual hosts next to gitlab.
Two are node.js web applications launched by a non-root user
running on two distinct ports > 1024
, the third is a PHP web application that need a web server to be launched from.
There are:
- a private bower registry running on
8081
(node.js
) - a private npm registry running on
8082
(node.js
) - a private composer registry (
PHP
)
But Omnibus listen 80 and doesn't seem to use neither Apache2 or Nginx, thus I can't use them to serve my PHP app and reverse-proxy my two other node apps.
What serving mechanics Gitlab Omnibus uses to
listen 80
? How should I create the three other virtual hosts to be able to provide the following vHosts ?
gitlab.mycompany.com
(:80
) -- already in usebower.mycompany.com
(:80
)npm.mycompany.com
(:80
)packagist.mycompany.com
(:80
)
As I would not like to change the nginx server for gitlab (with some other integrations), the safest way would be below solution.
also as per
Gitlab:Ningx =>Inserting custom settings into the NGINX config
edit the /etc/gitlab/gitlab.rb of your gitlab:
and sroll to nginx['custom_nginx_config'] and modify as below make sure to uncomment
create the new config dir:
and add content to your new config
and reconfigure gitlab to get the new settings inserted
to restart nginx
to check nginx error log:
About these
and @stdob comment :
Wich I responded
In facts
From Gitlab official docs :
So yes!
but it was bundled, explaining why it doesn't require to be installed as dependency from the host OS.
Thus YES! Nginx can, and should be used to serve my PHP app and reverse-proxy my two other node apps.
Then now
Omnibus-gitlab allows webserver access through user
gitlab-www
which resides in the group with the same name. To allow an external webserver access to GitLab, external webserver user needs to be addedgitlab-www
group.To use another web server like Apache or an existing Nginx installation you will have to do the following steps:
Disable bundled Nginx by specifying in
/etc/gitlab/gitlab.rb
Check the username of the non-bundled web-server user. By default,
omnibus-gitlab
has no default setting for external webserver user. You have to specify the external webserver user username in the configuration! Let's say for example that webserver user iswww-data
. In/etc/gitlab/gitlab.rb
setThis setting is an array so you can specify more than one user to be added to gitlab-www group.
Run
sudo gitlab-ctl reconfigure
for the change to take effect.Setting the NGINX listen address or addresses
By default NGINX will accept incoming connections on all local IPv4 addresses. You can change the list of addresses in
/etc/gitlab/gitlab.rb
.For GitLab CI, use the
ci_nginx['listen_addresses']
setting.Setting the NGINX listen port
By default NGINX will listen on the port specified in
external_url
or implicitly use the right port (80 for HTTP, 443 for HTTPS). If you are running GitLab behind a reverse proxy, you may want to override the listen port to something else. For example, to use port 8080:Similarly, for GitLab CI:
Supporting proxied SSL
By default NGINX will auto-detect whether to use SSL if
external_url
containshttps://
. If you are running GitLab behind a reverse proxy, you may wish to keep theexternal_url
as an HTTPS address but communicate with the GitLab NGINX internally over HTTP. To do this, you can disable HTTPS using thelisten_https
option:Similarly, for GitLab CI:
Note that you may need to configure your reverse proxy to forward certain headers (e.g.
Host
,X-Forwarded-Ssl
,X-Forwarded-For
,X-Forwarded-Port
) to GitLab.You may see improper redirections or errors (e.g. "422 Unprocessable Entity", "Can't verify CSRF token authenticity") if you forget this step. For more information, see:
Configuring our gitlab virtual host
Installing Phusion Passenger
We need to install ruby (gitlab run in omnibus with a bundled ruby) globally in the OS
Recompile nginx with the passenger module
Instead of
Apache2
for example, nginx isn't able to be plugged with binary modules on-the-fly. It must be recompiled for each new plugin you want to add.Phusion passenger developer team worked hard to provide saying, "a bundled nginx version of passenger" : nginx bins compiled with passenger plugin.
So, lets use it:
creatingpassenger.list
with these lignes
Edit permissions:
Updating package list:
Allowing it as
unattended-upgrades
Find or create this config block on top of the file:
Add the following:
Now (re)install
nginx-extra
andpassenger
:configure it
Uncomment the
passenger_root
andpassenger_ruby
directives in the/etc/nginx/nginx.conf
file:... to obtain something like:
create the nginx site configuration (the virtual host conf)
Now we can enable it:
It' done :-). Finally, restart nginx
With this new configuration, you are able to run other virtual hosts next to gitlab to serve what you want
Just create new configs in
/etc/nginx/sites-available
.node.js
node.js
For example, to serve
npm.mycompany.com
:Create a directory for logs:
And fill a new vhost config file:
With this config
Then enable it and restart it: