2016-01-26 50 views
1

我試圖在我的web服務器上安裝Gitlab。我恰當地配置了一切。這是什麼,我想實現一個方案:在同一臺服務器上的Apache和Nginx導致與gitlab發生衝突

  • example.com:80(默認主機)
    • vhost1.example.com:80(虛擬主機)
  • example.com:8080(gitlab)

那麼會發生什麼呢?我可以正常打開example.com和vhost1.example.com。如果gitlab-ctl停止,我得到一個「網站不可用」 - 如果我嘗試打開example.com:8080(如預期的那樣),則會出現錯誤。當我啓動gitlab並嘗試再次打開example.com:8080時,它會向我顯示gitlab錯誤「502錯誤GitLab需要花費太多時間來響應」,但只有在我第一次加載此頁面時,只要我刷新或者在新選項卡中再次嘗試,它會始終將我的請求重定向到example.com,儘管我在最後請求了帶有「:8080」的頁面。

我可以通過http://x.x.x.x:8080訪問gitlab。這工作,但我不得不配置http://example.com:8080

系統:

  • Debian的喘息
  • 的Apache/2.2.22
  • gitlab-ce_8.4.1-CE(包括nginx的)

這裏是我的配置文件:

/etc/apache2/sites-可用/ 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(僅改變)

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(僅改變)

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 

我真的很感激每一個提示。如果您需要進一步的信息,請詢問。

+0

考慮通過刪除Apache並使用Nginx作爲唯一的Web服務器來簡化情況。 –

+0

不幸的是這是一個要求。不知何故,我設法讓它工作。我會用我的解決方案爲其他人更新答案。 –

回答

2

經過一番修補之後,我找到了一個適合我的解決方案。如果某人在這裏遇到同樣的問題,請執行以下操作:

Apache配置正確,因此配置保持不變。

的/ etc/apache2的/網站可用/例子。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(僅改變)

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> 

由於gitlab.rb配置存在問題。解決方案不要改變太多。只有需要這些兩行gitlab工作:

/etc/gitlab/gitlab.rb(僅變更)

external_url 'http://git.example.com:8080' 
unicorn['port'] = 8081 

如果你不打算在8080端口上運行Gitlab,你不必爲獨角獸分配一個新的端口。不要忘記在更改後運行'gitlab-ctl reconfigure'。

相關問題