在本機部署gitlab后,如何在nginx上配置多域名?


 

之前在本機上部署了gitlab服務,可以通過localhost、127.0.0.1 和本機IP訪問到本機gitlab頁面。

現在想在本機建立一個網站做些測試,可是不知道怎么訪問到新建的網站,搜索了相關資料,據說要修改nginx的配置文件,我在配置文件里添加 myhome.cn 域名,並綁定到網站目錄,可是訪問 myhome.cn 后,打開的還是gitlab的頁面。

按照網上的相關說明,我又修改了gitlab的配置文件:

/opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
/opt/gitlab/embedded/service/gitlab-shell/config.yml

把 host 改成了 git.test.com,用gitlab-ctl restart命令重新啟動gitlab后效果也一樣。

/etc/hosts里也添加了域名:

127.0.0.1 git.test.com
127.0.0.1 myhome.cn

然而,並沒有什么用,不管什么域名,都是訪問gitlab的頁面,有沒有什么解決方法?


ps -ef | grep nginx命令看了下,發現運行的nginx的路徑是/opt/gitlab/embedded/sbin/nginx,而配置文件路徑是/var/opt/gitlab/nginx,怪不得我打開/etc/nginx/nginx.conf沒看到gitlab相關的配置。
試着改了下/var/opt/gitlab/nginx/nginx.conf 和 /var/opt/gitlab/nginx/gitlab-http.conf,重啟服務后,頁面無法訪問了,我先折騰一下。


/var/opt/gitlab/nginx/nginx.conf開頭處有這樣的內容:

# This file is managed by gitlab-ctl. Manual changes will be # erased! To change the contents below, edit /etc/gitlab/gitlab.rb # and run `sudo gitlab-ctl reconfigure`. 

呃,原來可以通過修改/etc/gitlab/gitlab.rb來配置,我再折騰一下。

 

server {
        listen 80; server_name git.test.com; access_log /var/log/nginx/XXX.access_log main; error_log /var/log/nginx/XXX.error_log info; root /home/www/xxx; index index.html index.php; //接下來配置github cgi接口 } server { listen 80; server_name myhome.cn; access_log /var/log/nginx/XXX.access_log main; error_log /var/log/nginx/XXX.error_log info; root /home/www/xxx2; index index.html index.php; //接下來配置別的cgi接口 }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM