0

バックグラウンド

Ubuntu 15.10

アパッチ/2.4.10 (Ubuntu)

モジュールの依存関係はすべて有効です:

  • mod_rewrite
  • mod_proxy
  • mod_proxy_http

GitLab コミュニティ版 8.0.3

GitLab docroot : /opt/gitlab/embedded/service/gitlab-rails/public

この方法で GitLab をインストールします: https://about.gitlab.com/downloads/#ubuntu1404

問題

私のサーバーには、apache2 (example-site.com) で実行されている Web サイトがあります。

バンドルされたnginx(exemple-gitlab.com)でGitLabを実行しています

1 つのサーバー、1 つの IP、および複数の FQDN があります。

このように、私のドメイン名はすべて GitLab を指しています。

したがって、 exemple-gitlab.com は必要に応じて GitLab を指しますが、 exemple-site.com は GitLab も指し、他のすべての FQDN も指します。

解決方法

私はしなければならないと思います(そして私は試みました):

  • バンドルされている nginx を無効にし、apache2 で gitlab を構成します (私には難しいことです)。
  • バンドルされている nginx を apache2 のリバース プロキシとして構成する (私には難しい)

MAJ : 実際、問題は Apache と bundled-nginx が同じポート (80) の同じ IP で実行されていることです。そして、ポート81などでWebサイトを実行したくはありません。ポート80のみです。

私はすべての PHP Web サイトで apache2 を使用することを好み、gitlab が apache2 を使用するかバンドルされた nginx を使用するかは気にしません。必要なのは、すべての FQDN を gitlab にリダイレクトするのではなく、各 Web サイトにすべての FQDN を使用することだけです。

理解

オムニバス、レール、リバース プロキシの仕組みがわかりません。

バンドルされているnginxを無効にしてみました/etc/gitlab/gitlab.rb

nginx['enable'] = false
# For GitLab CI, use the following:
ci_nginx['enable'] = false

グループに追加www-datagitlab-wwwて変更:

web_server['external_users'] = ['www-data']

変更した vhost.conf を apache2 に追加します https://gitlab.com/gitlab-org/gitlab-recipes/blob/master/web-server/apache/gitlab-apache24.conf

    <VirtualHost *:80>
    ServerName exemple-gitlab.com
    ServerSignature Off
    ProxyPreserveHost On

    AllowEncodedSlashes NoDecode

    <Location />
    Require all granted

    #Allow forwarding to gitlab-git-http-server
    ProxyPassReverse http://127.0.0.1:8181
    #Allow forwarding to GitLab Rails app (Unicorn)
    ProxyPassReverse http://127.0.0.1:8080
    ProxyPassReverse http://exemple-gitlab.com/
    </Location>

    #apache equivalent of nginx try files
    RewriteEngine on
    #Forward these requests to gitlab-git-http-server
    RewriteCond %{REQUEST_URI} ^/[\w\.-]+/[\w\.-]+/repository/archive.* [OR]
    RewriteCond %{REQUEST_URI} ^/api/v3/projects/.*/repository/archive.* [OR]
    RewriteCond %{REQUEST_URI} ^/[\w\.-]+/[\w\.-]+/(info/refs|git-upload-pack|git-receive-pack)$
    RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA]

    #Forward any other requests to GitLab Rails app (Unicorn)
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
    RewriteCond %{REQUEST_URI} ^/uploads
    RewriteRule .* http://127.0.0.1:8080%{REQUEST_URI} [P,QSA,NE]

    # needed for downloading attachments
    /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

    # /var/log/apache2.
    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded
    ErrorLog  /var/log/apache2/logs/gitlab.example.com_error.log
    CustomLog /var/log/apache2/logs/gitlab.example.com_forwarded.log common_forwarded
    CustomLog /var/log/apache2/logs/gitlab.example.com_access.log combined env=!dontlog
    CustomLog /var/log/apache2/logs/gitlab.example.com.log combined

  </VirtualHost>

しかし、このconfバグは私のapache2です:

~# systemctl status apache2.service
● apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2)
   Active: failed (Result: exit-code) since mar. 2015-11-10 15:41:08 CET; 1min 9s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 18315 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
  Process: 18342 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)

nov. 10 15:41:08 vpsxxx.ovh.net apache2[18342]: * The apache2 configtest failed.
nov. 10 15:41:08 vpsxxx.ovh.net apache2[18342]: Output of config test was:
nov. 10 15:41:08 vpsxxx.ovh.net apache2[18342]: (2)No such file or directory: AH02291: Cannot access di...f:10
nov. 10 15:41:08 vpsxxx.ovh.net apache2[18342]: AH00014: Configuration check failed
nov. 10 15:41:08 vpsxxx.ovh.net apache2[18342]: Action 'configtest' failed.
nov. 10 15:41:08 vpsxxx.ovh.net apache2[18342]: The Apache error log may have more information.
nov. 10 15:41:08 vpsxxx.ovh.net systemd[1]: apache2.service: Control process exited, code=exited status=1
nov. 10 15:41:08 vpsxxx.ovh.net systemd[1]: Failed to start LSB: Apache2 web server.
nov. 10 15:41:08 vpsxxx.ovh.net systemd[1]: apache2.service: Unit entered failed state.
nov. 10 15:41:08 vpsxxx.ovh.net systemd[1]: apache2.service: Failed with result 'exit-code'.
Hint: Some lines were ellipsized, use -l to show in full.
4

2 に答える 2

0

最も簡単な方法は、omnibus を使用して nginx をループバック アドレスにインストールして構成することですが、その前に apache をリバース プロキシとして使用します。

nginx を再度有効にして、以下を に追加するだけ/etc/gitlab/gitlab.rbです。

nginx['listen_addresses'] = ['127.0.1.1']

次に、gitlab のインストールを再構成します。

次に、Apache サイト構成で、次のようなものを使用します。

<VirtualHost *:80>
  ServerName exemple-gitlab.com
  ProxyPreserveHost On

  ProxyPass / http://127.0.1.1/
  ProxyPassReverse / http://127.0.1.1/
</VirtualHost>

オムニバスが nginx 構成を管理できるようにすることで、ユニコーン ワーカーから gitlab-git-http-server Go サーバーにサービスを移動するたびに Web サーバー構成を変更する必要がなくなります。Apache はリクエストを (ループバック上で) nginx にシームレスにプロキシし、更新中にオムニバスによって自動的に最新の状態に保たれます。

于 2015-11-10T16:37:44.643 に答える
0

Sorry I posted it on ServerFault and found the solution :

https://serverfault.com/questions/735270/gitlab-8-0-3-with-apache2-nginx/735273#735273

I found why apache2 crashed by commenting each line (damm logs were useless).

I just had to create /var/log/apache2/logs

 ErrorLog  /var/log/apache2/logs/gitlab.example.com_error.log
  CustomLog /var/log/apache2/logs/gitlab.example.com_forwarded.log common_forwarded
  CustomLog /var/log/apache2/logs/gitlab.example.com_access.log combined env=!dontlog
  CustomLog /var/log/apache2/logs/gitlab.example.com.log combined

apache2 was crashing because the folder/directory was missing ...

So now gitlab is working on is domain and my drupal too like this :

  • gitlab.com:80
  • drupal.com:80

Exactrly as I wanted :)

于 2015-11-11T17:33:46.320 に答える