我已经使用https://about.gitlab.com/downloads/中的默认软件包在Ubuntu 12.04上设置了Gitlab
{编辑澄清}
我已经build立了Apache来代理并运行安装在端口8888上的nginx服务器(或者我认为)。
由于我已经安装了Apache,我必须在localhost上运行nginx:8888。 问题是,所有图像(如头像)现在都从http://localhost:8888 ,而且所有的结帐url也是localhost – 而不是使用我的域名。
如果我更改/etc/gitlab/gitlab.rb使用该url,那么Gitlab停止工作,并给出503。
任何想法如何告诉Gitlab什么URL呈现给世界,即使它真的在本地主机上运行?
/etc/gitlab/gitlab.rb看起来像:
# Change the external_url to the address your users will type in their browser external_url 'http://my.local.domain' redis['port'] = 6379 postgresql['port'] = 2345 unicorn['port'] = 3456
和/opt/gitlab/embedded/conf/nginx.conf看起来像:
server { listen localhost:8888; server_name my.local.domain;
[更新]
如果我不指定localhost:8888作为external_url,它看起来像nginx仍在监听错误的端口。 我在/var/log/gitlab/nginx/error.log发现了这个
2014/08/19 14:29:58 [emerg] 2526#0: bind() to 0.0.0.0:80 failed (98: Address already in use) 2014/08/19 14:29:58 [emerg] 2526#0: bind() to 0.0.0.0:80 failed (98: Address already in use) 2014/08/19 14:29:58 [emerg] 2526#0: bind() to 0.0.0.0:80 failed (98: Address already in use) 2014/08/19 14:29:58 [emerg] 2526#0: bind() to 0.0.0.0:80 failed (98: Address already in use) 2014/08/19 14:29:58 [emerg] 2526#0: bind() to 0.0.0.0:80 failed (98: Address already in use) 2014/08/19 14:29:58 [emerg] 2526#0: still could not bind()
Apache设置看起来像:
<VirtualHost *:80> ServerName my.local.domain ServerSignature Off ProxyPreserveHost On AllowEncodedSlashes NoDecode <Location /> ProxyPass http://localhost:8888/ ProxyPassReverse http://127.0.0.1:8888 ProxyPassReverse http://my.local.domain </Location> </VirtualHost>
如果Gitlab监听本地主机,这似乎代理一切正常:8888 – 我只需要Gitlab开始显示正确的URL,而不是本地主机:8888。
根据Gitlab的github文档:
# Copy the example GitLab config sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml # Make sure to change "localhost" to the fully-qualified domain name of your # host serving GitLab where necessary
请确保Apache正在发送适当的代理标头。
在这种情况下,nginxconfiguration是无关的,因为你使用Apache来代理。 只需将其删除或closures。
我很伤心,没有人有明确的答案,这是它之间的许多其他职位和一些狡猾的conf编辑鹅卵石。 我把这些放在一个地方给你们,为了节省你我浪费的两个小时。
我的设置是我有一个Apache的托pipe许多网站和托pipeHTTPS,我configuration为一个反向代理指向gitlab。 所以我想要我的URL,gitlab在电子邮件中生成指向Apache的安全url。 所以要做到这一点…
在CentOS 7上,位于/opt/gitlab/embedded/cookbooks/gitlab/libraries/gitlab.rb
并改变线…
external_url nil
至
external_url "http://<yoururl>:81"
您的nginx现在将托pipe在端口81上,但是您通过电子邮件发送的URL将看起来像“http://:81”,而不是您的安全apache代理。 所以要做到这一点…
在CentOS 7上,它位于/var/opt/gitlab/gitlab-rails/etc/gitlab.yml
并改变线…
## Web server settings (note: host is the FQDN, do not include http://) host: <yoururl> port: 81 https: false
至
## Web server settings (note: host is the FQDN, do not include http://) host: <yoururl> port: 443 https: true
然后只要确保nginx正常启动,如果你需要,gitlab-ctl tail nginx,看看它吐出了什么错误。
警告:如果您再次运行gitlab-ctl reconfigure,则需要重新进行编辑。 我已经search了高低,并发现没有办法做到这一点,重新configuration处理它很好。 这是一个function要求有人可以要求gitlab添加,应该是相当小的。 一个可选variables“actual_url”,当被设置时用于任何生成的URL。
我最终遵循了这个文档,其中包括禁用nginx,让你的apache安装代理gitlab,这对我来说更有意义,反正我仍然有一些资产仍然加载的问题:8081当试图通过nginx代理
http://ryansechrest.com/2015/08/use-apache-instead-of-built-in-nginx-in-gitlab-ce/
vi /etc/gitlab/gitlab.rb
设置您的外部URL
external_url 'http://mygitlab.web.site/'
更改www用户和组
web_server['username'] = 'www-data' web_server['group'] = 'www-data'
禁用nginx
nginx['enable'] = false
为git服务器设置端口(在文件末尾)
gitlab_git_http_server['listen_network'] = "tcp" gitlab_git_http_server['listen_addr'] = "localhost:8282"
重新configurationgitlab
gitlab-ctl reconfigure
更改您的虚拟主机configuration
<VirtualHost *:80> ServerName git.domain.com DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public ProxyPreserveHost On AllowEncodedSlashes Off <Location /> Order deny,allow Allow from all ProxyPassReverse http://127.0.0.1:8080 ProxyPassReverse http://git.domain.com/ </Location> RewriteEngine on #Don't escape encoded characters in api requests RewriteCond %{REQUEST_URI} ^/api/v3/.* RewriteRule .* http://127.0.0.1:8080%{REQUEST_URI} [P,QSA,NE] #Forward all requests to gitlab-workhorse except existing files like error documents RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR] RewriteCond %{REQUEST_URI} ^/uploads/.* RewriteRule .* http://127.0.0.1:8282%{REQUEST_URI} [P,QSA] </VirtualHost>
重新启动gitlab
gitlab-ctl restart
我遇到了这个问题,虽然不是由于Apache代理。 我的安装是从主机到虚拟机的简单端口。 这个解决scheme应该适用于端口转发和代理的所有方法。 操作系统之间唯一可能改变的地方是Gitlabconfiguration文件的位置。 我正在使用Debian 7.8和Gitlab 7.8.4
简答 :
在/etc/gitlab/gitlab.rb进行以下更改:
external_url从'http://gitlab.example.com/'更改为'http://gitlab.example.com:8080' nginx['custom_gitlab_server_config'] = "listen *:80;" 最后的注意事项 : – Gitlab的Nginx无法在“内部”机器上运行:8080(代理/端口转发指向的内容)
长答案 :
这包括更多有关我的设置和find解决scheme的过程的背景信息
我的设置:
computer.local :主机
computer-vm.local:80 computer-vm.local:22 computer-vm.local :Debian虚拟机,其中安装了Gitlab和其他软件。 该虚拟机不使用桥接networking,所以任何从外部访问的端口都必须从主机转发。
注意:在每次更改/etc/gitlab/gitlab.rb之后,我运行了sudo gitlab-ctl reconfigure
使用在他们的下载页面上find的标准安装说明,可以通过computer.local:8080访问Gitlab实例。 我开始创build帐户,但发送的电子邮件链接使用URL http://computer-vm.local/users/confirmation?confirmation_token=... ,这是从任何计算机,而不是主机访问。 将/etc/gitlab/gitlab.rb中的/etc/gitlab/gitlab.rb从http://computer-vm.local更改为http://computer.local:8080将使Gitlab完全无法访问。 从主机导航到http://computer-vm.local:8080产生了“502:Gitlab没有响应错误”。 经过调查,似乎独angular兽试图在localhost:8080上收听localhost:8080 ,所以Nginx和Unicorn为同一个端口而战,Nginx赢了这场战斗,但是让Gitlab无用。 将external_url更改为http://computer.local:8081解决了在http://computer-vm.local:8081处可访问的Gitlab的502错误。 但这只是一个问题
我需要Gitlab来通告它的URL为'http://computer.local:8080'因为端口转发,我不想改变。 所以, external_url被改回http://computer.local:8080 。 在这里查看有关Nginx选项的Gitlab文档,没有提及如何在不更改完整的Gitlab外部URL(这是以前版本中的一个选项)的情况下更改Nginx端口。 但是,Gitlab允许用户通过nginx['custom_gitlab_server_config']选项将任意选项传递给Nginx。 我将以下内容添加到我的/etc/gitlab/gitlab.rb文件中:
nginx['custom_gitlab_server_config'] = "listen *:80;"
在重新configurationGitlab之后,瞧! 可从http://computer.local:8080 ,并且在发送密码重置链接和显示git clone链接时包含正确的域。
由于端口转发的情况,我还必须将gitlab_rails['gitlab_shell_ssh_port']从22更改为2222 ,但是您可能不需要。
我最后的/etc/gitlab/gitlab.rb :
external_url "computer.local:8080" gitlab_rails['gitlab_shell_ssh_port'] = 2222 nginx['custom_gitlab_server_config'] = "listen *:80;"
我有同样的问题,改变
external_url 'http://my.local.domain'
至
external_url 'http://my.local.domain:8888'
并重新生成gitlabconfiguration,这将修复nginxconfiguration。 Apache代理应该修复链接,以便8888被再次剥离。
希望这有助于,我结束了从现有的环境中删除gitlab,将启动一个干净的虚拟机为gitlab,因为它(在我看来)不适合现有的设置。
非常简单的方法来更改默认端口号
运行gitlab-ctl stop
在centos或linux中编辑文件: – /var/opt/gitlab/nginx/conf/gitlab-http.conf
改听*:80; 到你想要的例如: – 90
然后
不要运行命令 – gitlab-ctl reconfigure
如果gitlab-ctl重新configuration默认configurationgitlab并删除更改。
所以只能运行gitlab-ctl start
对于任何其他人来说,要支持:
鉴于此示例ProxyPassconfiguration:
ProxyPass /gitlab http://localhost:81/gitlab ProxyPassReverse /gitlab http://localhost:81/gitlab
在gitlab.rb中编辑两个参数并重新configuration。 脚步:
编辑/etc/gitlab/gitlab.rb。
更改: external_url 'http://my.local.domain/gitlab'
收件人: external_url 'http://my.local.domain/'
编辑/etc/gitlab/gitlab.rb
更改: # nginx['listen_port'] = nil
要: nginx['listen_port'] = 81
运行命令: gitlab-ctl reconfigure
完成。