Reputation: 31
I tried to install Gitlab on my webserver. 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. If gitlab-ctl is stopped, I get a "Website not available"-error if I try to open example.com:8080 (as expected). 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.
I have access to gitlab with http://x.x.x.x:8080. This works but I'm forced to configure http://example.com:8080
System:
Here are my configuration files:
/etc/apache2/sites-available/example.com
<VirtualHost *:80>
ServerAdmin [email protected]
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
<VirtualHost *:80>
ServerAdmin [email protected]
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)
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)
external_url 'http://example.com:8080'
unicorn['port'] = 8081
nginx['listen_addresses'] = ["x.x.x.x"]
nginx['listen_port'] = 8080
netstat -napl | 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.
Upvotes: 1
Views: 3660
Reputation: 31
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.
/etc/apache2/sites-available/example.com
<VirtualHost *:80>
ServerAdmin [email protected]
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
<VirtualHost *:80>
ServerAdmin [email protected]
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)
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. The solution is not to change too much. Only these two lines are needed for gitlab to work:
/etc/gitlab/gitlab.rb (only changes)
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. Do not forget to run 'gitlab-ctl reconfigure' after the changes.
Upvotes: 2