如何在gitlab中单独重启bundle nginx?

时间:2015-10-06 12:10:15

标签: nginx gitlab gitlab-omnibus

我已经安装了Gitlab CE版本。我可以在Gitlab中找到捆绑的nginx。但是我找不到分别重启nginx的方法。我试过sudo service nginx restart,但它给出了:

* Restarting nginx nginx                                     [fail] 

我检查了所有文件但找不到解决方案。我试图根据此tutorial将vhost添加到捆绑的nginx。但我坚持这一步。有没有其他方法将Ghost添加到Gitlab捆绑的nginx?或者我如何检查我的nginx配置是否有效?

编辑:502错误我已经解决了。

我尝试根据此doc使用NON-bundle nginx,但在我修改gitlab.rb并运行sudo gitlab-ctl reconfigure后,我遇到了502 Whoops, GitLab is taking too much time to respond.错误。

这是我的gitlab.conf 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;
}

3 个答案:

答案 0 :(得分:39)

要仅重新启动GitLab Omnibus的一个组件,您可以执行sudo gitlab-ctl restart <component>。因此,要重新启动Nginx:

sudo gitlab-ctl restart nginx

进一步说明,几乎所有gitlab-ctl命令都可以实现相同的概念。例如,sudo gitlab-ctl tail允许您查看所有GitLab日志。应用此概念,sudo gitlab-ctl tail nginx将只返回Nginx日志。

答案 1 :(得分:0)

我的tuto解释了如何将vhost添加到NON捆绑的nginx服务器,而不是捆绑的服务器。

步骤如下:

  • 禁用捆绑版本
  • 安装使用乘客模块编译的独立nginx版本,
  • 将其配置为将gitlab作为vhost提供
  • 然后在其上配置其他自定义虚拟主机。

如果sudo service nginx restart返回

* Restarting nginx nginx                                     [fail] 

然后你可能用sudo apt-get install nginx之类的东西单独安装了nginx,或者你在我的tuto中解释了你用pushion passenger module安装了重新编译的版本吗?

你真的使用捆绑版本,或者你在我的tuto中误解了这个步骤?

  

请在评论中回答这些问题,然后我将编辑此答案以编写您真正需要的解决方案。

答案 2 :(得分:0)

要重新启动捆绑的nginx,请执行sudo gitlab-ctl restart