[英]Apache & Nginx on same Server leads to conflict with gitlab
我試圖在我的網絡服務器上安裝Gitlab。 我適當地配置了所有內容。 這是我要實現的方案:
所以這是怎么回事:我可以正常打開example.com和vhost1.example.com。 如果gitlab-ctl已停止,如果嘗試打開example.com:8080(如預期的那樣),則會出現“網站不可用”錯誤。 當我啟動gitlab並嘗試再次打開example.com:8080時,它顯示出gitlab錯誤“ 502 Error GitLab花費了太多時間來進行響應”,但這只是我第一次刷新此頁面時的第一次刷新或在新標簽中再試一次,盡管我請求的頁面末尾帶有“:8080”,但它始終將我的請求重定向到example.com。
我可以使用http:// xxxx:8080訪問gitlab。 這可行,但是我不得不配置http://example.com:8080
系統:
這是我的配置文件:
/etc/apache2/sites-available/example.com
<VirtualHost *:80>
ServerAdmin mail@example.com
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 mail@example.com
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
我真的很感謝所有提示。 如果您需要更多信息,請詢問。
經過一番修補,我找到了一個對我有用的解決方案。 如果有人遇到相同的問題,您可以執行以下操作:
Apache已正確配置,因此配置保持原樣。
/etc/apache2/sites-available/example.com
<VirtualHost *:80>
ServerAdmin mail@example.com
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 mail@example.com
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'。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.