webGuy
webGuy

Reputation: 163

run gitlab with apache

I am trying to run gitlab on ubuntu 20.04 LTS with apache. I followed the official installation guide: https://about.gitlab.com/install/#ubuntu

When i open my gitlab on git.domain.de i only see the "Deploy in progress" error page. I see the following error in my logs:

[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/

My apache sites-available config looks like this:

<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>

Upvotes: 7

Views: 5108

Answers (1)

mahen3d
mahen3d

Reputation: 7734

When you run gitlab with Apache you need few more configuration steps.

Install dependencies

sudo apt-get install apache2
sudo apt-get install curl openssh-server ca-certificates postfix

Configure Gitlab to use Apache

sudo vim /etc/gitlab/gitlab.rb

Changes needed for the files.

  1. Change "nginx['enable'] = true" to "nginx['enable'] = false"

  2. Change "web_server['external_users'] = []" to "web_server['external_users'] = ['www-data']"

  3. Change "gitlab_rails['trusted_proxies']" to your web servers IP address. e.g. gitlab_rails['trusted_proxies'] = ['10.128.0.2']

  4. Change "gitlab_workhorse['listen_network'] = "unix" to gitlab_workhorse['listen_network'] = "tcp"

  5. Change gitlab_workhorse['listen_addr'] = "/var/opt/gitlab/gitlab-workhorse/socket" to gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"

  6. Change "unicorn['port'] = 8080" to "unicorn['port'] = 8082"

Update Gitlab ports Create or edit the file:

vim /etc/default/gitlab

Add/update below,

gitlab_workhorse_options="-listenUmask 0 -listenNetwork tcp -listenAddr 127.0.0.1:8181 -authBackend http://127.0.0.1:8082"

Reload the new Gitlab configuration

sudo gitlab-ctl reconfigure

Enable Apache mod_proxy & mod_rewrite

sudo a2enmod proxy; 
sudo a2enmod rewrite; 
sudo a2enmod proxy_http;

Create Apache Config for Gitlab

sudo vim /etc/apache2/sites-available/gitlab.conf

Enable the apache config:

sudo a2ensite gitlab

Restart apache:

sudo service apache2 restart

Upvotes: 7

Related Questions