【问题标题】:Installed gitlab, but only nginx welcome page shows安装了gitlab,但只显示nginx欢迎页面
【发布时间】:2023-03-14 11:49:01
【问题描述】:

我使用它的installation guide 安装了 gitlab。一切正常,但是当我在浏览器中打开 localhost:80 时,我看到的都是消息 Welcome to nginx!。我找不到任何有任何错误的日志文件。

我在 VirtualBox 中运行 Ubuntu。我的 /etc/nginx/sites-enabled/gitlab 配置文件内容如下:

# GITLAB
# Maintainer: @randx
# App Version: 3.0

upstream gitlab {
  server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket;
}

server {
  listen 192.168.1.1:80;         # e.g., listen 192.168.1.1:80;
  server_name aridev-VirtualBox;     # e.g., server_name source.example.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_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
    proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
    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_pass http://gitlab;
  }
}

【问题讨论】:

标签: nginx gitlab


【解决方案1】:

nginx documentation 说:

Server names are defined using the server_name directive and determine which server block is used for a given request. 

这意味着在您的情况下,您必须在浏览器中输入 aridev-VirtualBox 而不是 localhost。

要使其正常工作,您必须在本地 Hosts file 中输入 aridev-VirtualBox 并将其指向您的 VirtualBox PC 的 IP。

如下所示:

192.168.1.1 aridev-VirtualBox

【讨论】:

    【解决方案2】:

    我删除了/etc/nginx/sites-enabled/default 以解决这个问题。

    【讨论】:

    • 没有骰子,对不起。 nginx重启后导致“Bad gateway”。
    • 这适用于 ubuntu 13.04 上从 apt-get 安装 nginx 的人。
    【解决方案3】:

    尝试遵循 orkoden 的建议,从 /etc/nginx/sites-enabled/ 中删除默认站点,但也要注释掉您的 listen 行,因为默认的隐含行应该足够了。

    另外,请确保在对这些配置进行更改时,将 gitlab 和 nginx 服务都关闭,并按照先 gitlab 后 nginx 的顺序启动它们。

    【讨论】:

      【解决方案4】:

      您的配置文件是正确的。 # /etc/nginx/sites-enabled/gitlab

      也许我认为你的 gitlab 文件链接有误。

      所以例子:

      ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/gitlab

      请检查默认内容 == 你的 /etc/nginx/sites-enabled/gitlab 内容

      之后

      【讨论】:

        【解决方案5】:

        我改变了这一行:

        proxy_pass http://gitlab;
        

        通过这个:

        proxy_pass http://localhost:3000;
        

        3000 是我的独角兽服务器的端口。

        此外,我在 conf 文件上做了一个chown root:ngnix,它现在可以工作了。

        【讨论】:

          【解决方案6】:

          老话题,不过有可能会出现之前安装过nginx的情况。
          $ gitlab-ctl reconfigure
          或重启不会抱怨,但之前的 nginx 实例实际上可能正在运行,而不是 gitlab 下的那个。
          这只是发生在我身上。

          关闭并禁用这个旧的 nginx 实例,然后再做一次:
          $ gitlab-ctl reconfigure

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2018-08-01
            • 1970-01-01
            • 1970-01-01
            • 2012-02-05
            • 2013-05-11
            • 1970-01-01
            • 2019-12-09
            • 1970-01-01
            相关资源
            最近更新 更多