search

Home  >  Q&A  >  body text

web server - how to configure multiple domain names on nginx after deploying gitlab locally?

The gitlab service was deployed on this machine before, and the local gitlab page can be accessed through localhost, 127.0.0.1 and the local IP.

Now I want to build a website on this machine to do some testing, but I don’t know how to access the newly created website. I searched for relevant information. It is said that I need to modify the nginx configuration file. I added the myhome.cn domain name to the configuration file, and It is bound to the website directory, but after accessing myhome.cn, the gitlab page is still opened.

Following the relevant instructions on the Internet, I modified the gitlab configuration file:

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

Change the host to git.test.com and use the gitlab-ctl restart command to restart gitlab and the effect will be the same.

The domain name has also been added to

/etc/hosts:

127.0.0.1 git.test.com
127.0.0.1 myhome.cn

However, it is of no use. Regardless of the domain name, the page of gitlab is accessed. Is there any solution?


Use the ps -ef | grep nginx command to check and find that the path of the running nginx is /opt/gitlab/embedded/sbin/nginx, and the configuration file path is /var/opt/gitlab/nginx, no wonder I didn’t see the gitlab related configuration when I opened /etc/nginx/nginx.conf.
Try changing /var/opt/gitlab/nginx/nginx.conf and /var/opt/gitlab/nginx/gitlab-http.conf. After restarting the service, the page I can't access it anymore. I'll give it a try first.


There is this content at the beginning of /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`.

Well, it turns out that it can be configured by modifying /etc/gitlab/gitlab.rb. I will give it a try.

过去多啦不再A梦过去多啦不再A梦2773 days ago936

reply all(4)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-05-16 17:26:46

    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接口
    }
    

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-16 17:26:46

    It’s fine if two nginx coexist. As long as the ports don’t conflict, there will be no problem.

    reply
    0
  • 阿神

    阿神2017-05-16 17:26:46

    Can I ask how you solved it in the end? Thank you very much, I encountered the same problem.

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-16 17:26:46

    I also encountered this problem, the page cannot be accessed

    reply
    0
  • Cancelreply