Run Redmine and Gitlab on unique apache server

I work on a project where im supposed to run simultaneously GitLab and Redmine on the same virtual machine using apache2. I started to install omnibus-GitLab (documented here https://about.gitlab.com/installation/#ubuntu) and edited the gitlab.rb to make it usable with apache2 (documented here https://docs.gitlab.com/omnibus/settings/nginx.html#using-a-non-bundled-web-server). Gitlab worked (url = my_ip/gitlab) before the redmine installation but after this installation (documented here : http://www.redmine.org/projects/redmine/wiki/howto_install_redmine_on_ubuntu_step_by_step) GitLab return a 404 (redmine works well on url my_ip/redmine). The only thing I could figure out is that GitLab is working again when I disable the redmine vhost. Here is my vhost :

GitLab vhost (found here https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/web-server/apache) :

# This configuration has been tested on GitLab 8.2
# Note this config assumes unicorn is listening on default port 8080 and
# gitlab-workhorse is listening on port 8181. To allow gitlab-workhorse to
# listen on port 8181, edit /etc/gitlab/gitlab.rb and change the following:
#
# gitlab_workhorse['listen_network'] = "tcp"
# gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"
#
#Module dependencies
# mod_rewrite
# mod_proxy
# mod_proxy_http
<VirtualHost *:80>
  ServerSignature Off

  ProxyPreserveHost On

  # Ensure that encoded slashes are not decoded but left in their encoded state.
  # http://doc.gitlab.com/ce/api/projects.html#get-single-project
  AllowEncodedSlashes NoDecode

  <Location />
    # New authorization commands for apache 2.4 and up
    # http://httpd.apache.org/docs/2.4/upgrading.html#access
    Require all granted

    #Allow forwarding to gitlab-workhorse
    ProxyPassReverse http://127.0.0.1:8181
  </Location>

  # Apache equivalent of nginx try files
  # http://serverfault.com/questions/290784/what-is-apaches-equivalent-of-nginxs-try-files
  # http://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab
  RewriteEngine on

  #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:8181%{REQUEST_URI} [P,QSA,NE]

  # 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 502 /502.html
  ErrorDocument 503 /503.html

</VirtualHost>

Redmine vhost (found here : http://www.redmine.org/projects/redmine/wiki/howto_install_redmine_on_ubuntu_step_by_step)

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
        <Directory /var/www/html/redmine>
                RailsBaseURI /redmine
                PassengerResolveSymlinksInDocumentRoot on
        </Directory>
</VirtualHost>

The solution im trying to focus on is one and only conf file including both vhosts

1
задан 17 May 2018 в 21:54
1 ответ

Ни одна из ваших директив VirtualHost не содержит директивы ServerName . Это очень важно, если вы хотите работать с виртуальными хостами на основе имен.

Пример для Gitlab

<VirtualHost *:80>
    ServerName gitlab.example.com
    ...
</VirtualHost>

и для Redmine

<VirtualHost *:80>
    ServerName redmine.example.com
    ...
</VirtualHost

ServerName должен совпадать с доменом, к которому вы подключаетесь . Если у вас нет подходящего ServerName , он будет соответствовать первому доступному VirtualHost .

Дополнительную информацию о виртуальных хостах на основе имен можно найти на https: / /httpd.apache.org/docs/2.4/vhosts/name-based.html[1166297ght.

2
ответ дан 3 December 2019 в 20:14

Теги

Похожие вопросы