I have installed Gitlab CE version. I can find nginx bundled in Gitlab. However I cannot find a way to restart nginx separately. I have tried sudo service nginx restart
but it gives:
* Restarting nginx nginx [fail]
I have checked all the document but cannot find a solution. I am trying to add vhost to the bundled nginx according to this tutorial. But I stuck at that step. Is there other way to add vhost to bundled nginx with Gitlab? Or How can I check whether my nginx conf work?
Edit: 502 error I have solved.
I try to use NON-bundle nginx according to this doc , But after I modify gitlab.rb
and run sudo gitlab-ctl reconfigure
, I got 502 Whoops, GitLab is taking too much time to respond.
error.
Here is my gitlab.conf
for nginx.
upstream gitlab {
server unix://var/opt/gitlab/gitlab-git-http-server/sockets/gitlab.socket fail_timeout=0;
#
}
server {
listen *:80;
server_name blcu.tk;
server_tokens off;
root /opt/gitlab/embedded/service/gitlab-rails/public;
client_max_body_size 250m;
access_log /var/log/gitlab/nginx/gitlab_access.log;
error_log /var/log/gitlab/nginx/gitlab_error.log;
# Ensure Passenger uses the bundled Ruby version
passenger_ruby /opt/gitlab/embedded/bin/ruby;
# Correct the $PATH variable to included packaged executables
passenger_env_var PATH "/opt/gitlab/bin:/opt/gitlab/embedded/bin:/usr/local/bin:/usr/bin:/bin";
# Make sure Passenger runs as the correct user and group to
# prevent permission issues
passenger_user git;
passenger_group git;
# Enable Passenger & keep at least one instance running at all times
passenger_enabled on;
passenger_min_instances 1;
location / {
try_files $uri $uri/index.html $uri.html @gitlab;
}
location @gitlab {
# If you use https make sure you disable gzip compression
# to be safe against BREACH attack
proxy_read_timeout 300; # Some requests take more than 30 seconds.
proxy_connect_timeout 300; # Some requests take more than 30 seconds.
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_pass http://gitlab;
}
location ~ ^/(assets)/ {
root /opt/gitlab/embedded/service/gitlab-rails/public;
# gzip_static on; # to serve pre-gzipped version
expires max;
add_header Cache-Control public;
}
error_page 502 /502.html;
}
To restart only one component of GitLab Omnibus you can execute sudo gitlab-ctl restart <component>
. Therefore, to restart Nginx:
sudo gitlab-ctl restart nginx
As a further note, this same concept is possible with nearly all of the gitlab-ctl
commands. For example, sudo gitlab-ctl tail
allows you to see all GitLab logs. Applying this concept, sudo gitlab-ctl tail nginx
will tail only Nginx logs.