[英]Apache & Nginx on same Server leads to conflict with gitlab
I tried to install Gitlab on my webserver. 我试图在我的网络服务器上安装Gitlab。 I configured everything appropriately. 我适当地配置了所有内容。 This is a scheme of what I am trying to achieve: 这是我要实现的方案:
So what happens is this: I can open example.com and vhost1.example.com normally. 所以这是怎么回事:我可以正常打开example.com和vhost1.example.com。 If gitlab-ctl is stopped, I get a "Website not available"-error if I try to open example.com:8080 (as expected). 如果gitlab-ctl已停止,如果尝试打开example.com:8080(如预期的那样),则会出现“网站不可用”错误。 When I start gitlab and try to open example.com:8080 again, it shows me the gitlab-error "502 Error GitLab is taking too much time to respond", but only the first time I load this page, as soon as I refresh or try it again in a new tab, it redirects my request always to example.com, although I request the page with ":8080" at the end. 当我启动gitlab并尝试再次打开example.com:8080时,它显示出gitlab错误“ 502 Error GitLab花费了太多时间来进行响应”,但这只是我第一次刷新此页面时的第一次刷新或在新标签中再试一次,尽管我请求的页面末尾带有“:8080”,但它始终将我的请求重定向到example.com。
I have access to gitlab with http://xxxx:8080 . 我可以使用http:// xxxx:8080访问gitlab。 This works but I'm forced to configure http://example.com:8080 这可行,但是我不得不配置http://example.com:8080
System: 系统:
Here are my configuration files: 这是我的配置文件:
/etc/apache2/sites-available/example.com /etc/apache2/sites-available/example.com
<VirtualHost *:80>
ServerAdmin mail@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com
ErrorLog ${APACHE_LOG_DIR}/error_example.com.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/example.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
/etc/apache2/sites-available/vhost1.example.com /etc/apache2/sites-available/vhost1.example.com
<VirtualHost *:80>
ServerAdmin mail@example.com
ServerName vhost1.example.com
ServerAlias www.vhost1.example.com
DocumentRoot /var/www/vhost1.example.com
ErrorLog ${APACHE_LOG_DIR}/error_vhost1.example.com.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/vhost1.example.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
/etc/apache2/ports.conf (only changes) /etc/apache2/ports.conf(仅更改)
NameVirtualHost *:80
Listen x.x.x.x:80
<IfModule mod_ssl.c>
Listen x.x.x.x:443
</IfModule>
<IfModule mod_gnutls.c>
Listen x.x.x.x:443
</IfModule>
/etc/gitlab/gitlab.rb (only changes) /etc/gitlab/gitlab.rb(仅更改)
external_url 'http://example.com:8080'
unicorn['port'] = 8081
nginx['listen_addresses'] = ["x.x.x.x"]
nginx['listen_port'] = 8080
netstat -napl | netstat -napl | grep :80 grep:80
tcp 0 0 x.x.x.x:8080 0.0.0.0:* LISTEN 19037/nginx
tcp 0 0 x.x.x.x:80 0.0.0.0:* LISTEN 18280/apache2
tcp 0 0 127.0.0.1:8081 0.0.0.0:* LISTEN 19110/config.ru
I would really appreciate every hint. 我真的很感谢所有提示。 If you need further information just ask. 如果您需要更多信息,请询问。
After some tinkering I found a solution that worked for me. 经过一番修补,我找到了一个对我有用的解决方案。 If someone has the same problem here you go: 如果有人遇到相同的问题,您可以执行以下操作:
Apache was configured correctly, so the configuration stays as is. Apache已正确配置,因此配置保持原样。
/etc/apache2/sites-available/example.com /etc/apache2/sites-available/example.com
<VirtualHost *:80>
ServerAdmin mail@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com
ErrorLog ${APACHE_LOG_DIR}/error_example.com.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/example.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
/etc/apache2/sites-available/vhost1.example.com /etc/apache2/sites-available/vhost1.example.com
<VirtualHost *:80>
ServerAdmin mail@example.com
ServerName vhost1.example.com
ServerAlias www.vhost1.example.com
DocumentRoot /var/www/vhost1.example.com
ErrorLog ${APACHE_LOG_DIR}/error_vhost1.example.com.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/vhost1.example.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
/etc/apache2/ports.conf (only changes) /etc/apache2/ports.conf(仅更改)
NameVirtualHost *:80
Listen x.x.x.x:80
<IfModule mod_ssl.c>
Listen x.x.x.x:443
</IfModule>
<IfModule mod_gnutls.c>
Listen x.x.x.x:443
</IfModule>
The problem existed because of the gitlab.rb configuration. 由于存在gitlab.rb配置,因此存在该问题。 The solution is not to change too much. 解决的办法是不要改变太多。 Only these two lines are needed for gitlab to work: gitlab仅需要这两行即可工作:
/etc/gitlab/gitlab.rb (only changes) /etc/gitlab/gitlab.rb(仅更改)
external_url 'http://git.example.com:8080'
unicorn['port'] = 8081
If you're not planning to run Gitlab on Port 8080, you don't have to assign a new port for unicorn. 如果您不打算在端口8080上运行Gitlab,则不必为独角兽分配新的端口。 Do not forget to run 'gitlab-ctl reconfigure' after the changes. 更改后,请不要忘记运行'gitlab-ctl reconfigure'。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.