linux - 用 apache 运行 gitlab
问题描述
我正在尝试使用 apache 在 ubuntu 20.04 LTS 上运行 gitlab。我按照官方安装指南:https ://about.gitlab.com/install/#ubuntu
当我在 git.domain.de 上打开我的 gitlab 时,我只看到“正在部署”错误页面。我在日志中看到以下错误:
[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/
我的 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>
解决方案
当您使用 Apache 运行 gitlab 时,您需要更多的配置步骤。
安装依赖项
sudo apt-get install apache2
sudo apt-get install curl openssh-server ca-certificates postfix
配置 Gitlab 以使用 Apache
sudo vim /etc/gitlab/gitlab.rb
文件所需的更改。
将“nginx['enable'] = true”更改为“nginx['enable'] = false”
将“web_server['external_users'] = []”更改为“web_server['external_users'] = ['www-data']”
将“gitlab_rails['trusted_proxies']”更改为您的 Web 服务器 IP 地址。例如 gitlab_rails['trusted_proxies'] = ['10.128.0.2']
将 "gitlab_workhorse['listen_network'] = "unix" 更改为 gitlab_workhorse['listen_network'] = "tcp"
将 gitlab_workhorse['listen_addr'] = "/var/opt/gitlab/gitlab-workhorse/socket" 更改为 gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"
将“unicorn['port'] = 8080”更改为“unicorn['port'] = 8082”
更新 Gitlab 端口 创建或编辑文件:
vim /etc/default/gitlab
在下面添加/更新,
gitlab_workhorse_options="-listenUmask 0 -listenNetwork tcp -listenAddr 127.0.0.1:8181 -authBackend http://127.0.0.1:8082"
重新加载新的 Gitlab 配置
sudo gitlab-ctl reconfigure
启用 Apache mod_proxy & mod_rewrite
sudo a2enmod proxy;
sudo a2enmod rewrite;
sudo a2enmod proxy_http;
为 Gitlab 创建 Apache 配置
sudo vim /etc/apache2/sites-available/gitlab.conf
启用 apache 配置:
sudo a2ensite gitlab
重启阿帕奇:
sudo service apache2 restart
推荐阅读
- javascript - React Native - 在图像上添加蒙版圆圈覆盖
- c# - 为交易跟踪代码生成唯一的数字 ID
- c++ - 无法在 Visual Studio 中使用预编译头文件
- python - Scrapy - 从页面上的其他文本构建 xpath 响应时谓词无效
- python - 在 Python 中使用 NLTK 为序列解析单个树
- vue.js - Apex 线面积图未显示在 Vuejs 的页面上
- reactjs - 为什么我需要做 export const useAppDispatch = () => useDispatch
() 将 Typescript 与 React 一起使用时 - azure - Azure Devops Pipeline 返回:“无法将 Web 包部署到应用服务。内部服务器错误(代码:500)'
- amazon-dynamodb - 在响应映射模板中访问状态码
- c++ - 基于优化级别的特征切换类型和执行