nginx - 如何在 Gitlab Omnibus 服务器旁边为其他虚拟主机提供服务? [完整的逐步解决方案]

标签 nginx webserver virtualhost gitlab gitlab-omnibus

我安装了 Gitlab CE 在带有 的专用 Ubuntu 14.04 服务器版本上综合包 .

现在我想安装另外三个 虚拟主机 在 gitlab 旁边。

两个是由 non-root user 启动的 node.js Web 应用程序。在两个不同的 ports > 1024 上运行,第三个是需要从 Web 服务器启动的 PHP Web 应用程序。

有:

  • 8081 上运行的私有(private)凉亭注册表( node.js )
  • 8082 上运行的私有(private) npm 注册表( node.js )
  • 私有(private) Composer 注册表(PHP)

  • 但是综合听80 并且似乎既不使用 Apache2 也不使用 Nginx,因此我不能使用它们来服务我的 PHP 应用程序并反向代理我的其他两个节点应用程序 .

    What serving mechanics Gitlab Omnibus uses to listen 80 ? How should I create the three other virtual hosts to be able to provide the following vHosts ?

    • gitlab.mycompany.com (:80) -- already in use
    • bower.mycompany.com (:80)
    • npm.mycompany.com (:80)
    • packagist.mycompany.com (:80)

    最佳答案

    由于我不想为 gitlab 更改 nginx 服务器(与其他一些集成),所以最安全的方法是下面的解决方案。

    也按照

    Gitlab:Ningx =>Inserting custom settings into the NGINX config

    编辑你的 gitlab 的/etc/gitlab/gitlab.rb :

    nano /etc/gitlab/gitlab.rb
    

    并滚动到 nginx['custom_nginx_config'] 并进行如下修改,确保取消注释
    # Example: include a directory to scan for additional config files
    nginx['custom_nginx_config'] = "include /etc/nginx/conf.d/*.conf;"
    

    创建新的配置目录:
    mkdir -p /etc/nginx/conf.d/
    nano /etc/nginx/conf.d/new_app.conf
    

    并将内容添加到您的新配置中
    # my new app config : /etc/nginx/conf.d/new_app.conf
    # set location of new app 
    upstream new_app {
      server localhost:1234; # wherever it might be
    }
    # set the new app server
    server {
      listen *:80;
      server_name new_app.mycompany.com;
      server_tokens off;
      access_log  /var/log/new_app_access.log;
      error_log   /var/log/new_app_error.log;
      proxy_set_header Host      $host;
      proxy_set_header X-Real-IP $remote_addr;
      location / { proxy_pass  http://new_app; }
    }
    

    并重新配置 gitlab 以插入新设置
    gitlab-ctl reconfigure
    

    重启 nginx
    gitlab-ctl restart nginx
    

    检查 nginx 错误日志:
    tail -f /var/log/gitlab/nginx/error.log
    

    关于nginx - 如何在 Gitlab Omnibus 服务器旁边为其他虚拟主机提供服务? [完整的逐步解决方案],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31762841/

    相关文章:

    apache - Rust 的 Web 服务器就像 Apache 到 PHP

    apache - 配置Apache Web服务器以使用代理服务器

    development-environment - 用于开发的虚拟桌面环境

    linux-kernel - 在虚拟服务器上运行 docker - 可能与否?

    cakephp - 如何在nginx中配置cakephp

    grails - Grails 应用程序中有许多持久的 CLOSE_WAIT 连接

    linux - 无法重启 nginx

    php - 全新安装的 laravel 5.6 在索引页面中获取 HTTP ERROR 500

    http - 如何启用nginx代理通行证?

    apache - 多个虚拟主机的一个 IP 地址和通配符证书(Windows、Apache 2.4.2、OpenSSL 1.0.2e)