![无法使用 Apache 和 Tomcat 在端口 80 上运行 GitLab](https://linux22.com/image/657205/%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8%20Apache%20%E5%92%8C%20Tomcat%20%E5%9C%A8%E7%AB%AF%E5%8F%A3%2080%20%E4%B8%8A%E8%BF%90%E8%A1%8C%20GitLab.png)
我使用 Omnibus 安装程序安装了 GitLab。目前,它使用在端口 81 上运行的 Nginx(GitLab 与之捆绑)正常工作。我将端口 80 更改为端口 81,因为我的 Apache 在端口 80 上运行。我还在端口 8080 上安装并运行了 Tomcat,因此我将 Unicorn 端口更改为 8081。所有这些都正常工作。以下是我更改的设置:
/etc/gitlab/gitlab.rb
# https://gitlab.com/gitlab-org/omnibus-gitlab/blob/629def0a7a26e7c2326566f0758d4a27857b52a3/README.md#configuring-the-external-url-for-gitlab
external_url 'http://mysite.example.net:81'
#https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#tcp-ports-for-gitlab-services-are-already-taken
unicorn['port'] = 8081
#https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#storing-git-data-in-an-alternative-directory
git_data_dir "/mnt/tank/gitlab"
/var/opt/gitlab/gitlab-rails/etc/gitlab.yml
production: &base
#
# 1. GitLab app settings
# ==========================
## GitLab settings
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host: mysite.example.net
port: 81
https: false
不幸的是我需要 GitLab 在端口 80 上运行。我尝试了几种 Apache 虚拟主机配置。我唯一成功的是我可以输入 URLhttp://mysite.example.com/gitlab
并得到 404 错误,但我看到 URL 更改为http://mysite.example.com/users/sign_in
。重定向导致gitlab
被删除,但如果我将其放回以获取 URL,http://mysite.example.com/gitlab/users/sign_in
我可以看到 GitLab 登录页面,尽管它全部被劫持,因为没有一个图像是正确的。我用来实现这些结果的配置如下:
/etc/gitlab/gitlab.rb
# https://gitlab.com/gitlab-org/omnibus-gitlab/blob/629def0a7a26e7c2326566f0758d4a27857b52a3/README.md#configuring-the-external-url-for-gitlab
external_url 'http://mysite.example.com'
#https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#tcp-ports-for-gitlab-services-are-already-taken
unicorn['port'] = 8081
#https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#storing-git-data-in-an-alternative-directory
git_data_dir "/mnt/tank/gitlab"
#https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/nginx.md#using-a-non-bundled-web-server
nginx['enable'] = false
web_server['external_users'] = ['www-data']
/etc/apache2/apache2.conf
ServerName mysite.example.com
ProxyRequests Off
<Proxy *>
Order Allow,Deny
Allow from all
</Proxy>
# transmission
ProxyPass /transmission http://localhost:9091/transmission
ProxyPassReverse /transmission http://localhost:9091/transmission
# gitlab
ProxyPass /gitlab http://localhost:8081
ProxyPassReverse /gitlab http://localhost:8081
/var/opt/gitlab/gitlab-rails/etc/gitlab.yml
production: &base
#
# 1. GitLab app settings
# ==========================
## GitLab settings
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host: mysite.example.com
port: 80
https: false
答案1
我遇到了类似的问题,想要使用 apache 设置 gitlab,但我不知道我的解决方案是否适用于您的情况:
我为子域“gitlab.example.com”设置了 DNS 记录以指向域“example.com”,并为子域添加了虚拟主机。这使我能够让代理为“/”而不是“/gitlab”工作。以下是我的配置文件:
/etc/gitlab/gitlab.rb:
external_url 'http://localhost:81'
虚拟主机(在 /etc/apache2/apache2.conf 中)
<VirtualHost *:80>
ServerName gitlab.example.com
ProxyPass / http://localhost:81
ProxyPassReverse / http://localhost:81
</VirtualHost>
这样我就可以通过'http://gitlab.example.com‘