简体   繁体   English

使用 apache 运行 gitlab

[英]run gitlab with apache

I am trying to run gitlab on ubuntu 20.04 LTS with apache.我正在尝试使用 apache 在 ubuntu 20.04 LTS 上运行 gitlab。 I followed the official installation guide: https://about.gitlab.com/install/#ubuntu我按照官方安装指南: https://about.gitlab.com/install/#ubuntu

When i open my gitlab on git.domain.de i only see the "Deploy in progress" error page.当我在 git.domain.de 上打开我的 gitlab 时,我只看到“正在部署”错误页面。 I see the following error in my logs:我在日志中看到以下错误:

[proxy:error] [pid 2267591:tid 139801344845568] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:8080 (*) failed
[proxy_http:error] [pid 2267591:tid 139801344845568] [client 91.64.235.xxx:51508] AH01114: HTTP: failed to make connection to backend: 127.0.0.1
[proxy:error] [pid 2267592:tid 139801344845568] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:8080 (*) failed
[proxy_http:error] [pid 2267592:tid 139801344845568] [client 91.64.235.xxx:51513] AH01114: HTTP: failed to make connection to backend: 127.0.0.1, referer: http://git.domain.de/

My apache sites-available config looks like this:我的 apache 站点可用配置如下所示:

<VirtualHost *:80>

  ServerName git.domain.de
  ServerSignature Off

  ProxyPreserveHost On
  AllowEncodedSlashes NoDecode

  <Location />
  Require all granted

  ProxyPassReverse http://127.0.0.1:8080
  ProxyPassReverse http://git.domain.de
  </Location>

  RewriteEngine on
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule .* http://127.0.0.1:8080%{REQUEST_URI} [P,QSA]

  # needed for downloading attachments
  DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public

  #Set up apache error documents, if back end goes down (i.e. 503 error) then a maintenance/deploy page is thrown up.
  ErrorDocument 404 /404.html
  ErrorDocument 422 /422.html
  ErrorDocument 500 /500.html
  ErrorDocument 503 /deploy.html

...

</VirtualHost>

When you run gitlab with Apache you need few more configuration steps.当您使用 Apache 运行 gitlab 时,您需要更多的配置步骤。

Install dependencies安装依赖项

sudo apt-get install apache2
sudo apt-get install curl openssh-server ca-certificates postfix

Configure Gitlab to use Apache配置 Gitlab 使用 Apache

sudo vim /etc/gitlab/gitlab.rb

Changes needed for the files.文件所需的更改。

  1. Change "nginx['enable'] = true" to "nginx['enable'] = false"将“nginx['enable'] = true”更改为“nginx['enable'] = false”

  2. Change "web_server['external_users'] = []" to "web_server['external_users'] = ['www-data']"将“web_server['external_users'] = []”更改为“web_server['external_users'] = ['www-data']”

  3. Change "gitlab_rails['trusted_proxies']" to your web servers IP address.将“gitlab_rails['trusted_proxies']”更改为您的 web 服务器 IP 地址。 eg gitlab_rails['trusted_proxies'] = ['10.128.0.2']例如 gitlab_rails['trusted_proxies'] = ['10.128.0.2']

  4. Change "gitlab_workhorse['listen_network'] = "unix" to gitlab_workhorse['listen_network'] = "tcp"将 "gitlab_workhorse['listen_network'] = "unix" 更改为 gitlab_workhorse['listen_network'] = "tcp"

  5. Change gitlab_workhorse['listen_addr'] = "/var/opt/gitlab/gitlab-workhorse/socket" to gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"将 gitlab_workhorse['listen_addr'] = "/var/opt/gitlab/gitlab-workhorse/socket" 更改为 gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"

  6. Change "unicorn['port'] = 8080" to "unicorn['port'] = 8082"将“unicorn['port'] = 8080”更改为“unicorn['port'] = 8082”

Update Gitlab ports Create or edit the file:更新 Gitlab 端口 创建或编辑文件:

vim /etc/default/gitlab

Add/update below,在下面添加/更新,

gitlab_workhorse_options="-listenUmask 0 -listenNetwork tcp -listenAddr 127.0.0.1:8181 -authBackend http://127.0.0.1:8082"

Reload the new Gitlab configuration重新加载新的 Gitlab 配置

sudo gitlab-ctl reconfigure

Enable Apache mod_proxy & mod_rewrite启用 Apache mod_proxy & mod_rewrite

sudo a2enmod proxy; 
sudo a2enmod rewrite; 
sudo a2enmod proxy_http;

Create Apache Config for Gitlab为 Gitlab 创建 Apache 配置

sudo vim /etc/apache2/sites-available/gitlab.conf

Enable the apache config:启用 apache 配置:

sudo a2ensite gitlab

Restart apache:重启apache:

sudo service apache2 restart

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM