gpt4 book ai didi

nginx - 使用gitlab的Nginx服务另一个应用程序

转载 作者:行者123 更新时间:2023-12-03 09:11:45 25 4
gpt4 key购买 nike

您好我已经使用此工具安装了Gitlab
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#installation

现在我想使用Nginx来提供gitlab应用程序以外的其他内容
我怎样才能做到这一点

  • 我需要修改
  • 的配置文件在哪里
  • 如何指向/ var / www之类的目录,以便nginx知道这是另一个应用程序的根目录。

  • 更新(忘了我在Red Hat 6.5下运行此程序,欢迎使用Debian / Ubuntu解决方案)

    最佳答案

    我在这里用

    - gitlab.example.com to serve gitlab.example.com over https.
    - example.com over http to serve another content other than gitlab application.

    从deb软件包安装的Gitlab正在使用Chef来配置ngnix,因此您必须修改Chef食谱并将新的vhost模板添加到Chef Cookbooks目录中

    您可以在这里找到所有厨师食谱:
    / opt / gitlab / embedded / cookbooks / gitlab /

    打开
    /opt/gitlab/embedded/cookbooks/gitlab/recipes/nginx.rb

    更改:
    nginx_vars = node['gitlab']['nginx'].to_hash.merge({
    :gitlab_http_config => File.join(nginx_etc_dir, "gitlab-http.conf"),
    })

    至:
    nginx_vars = node['gitlab']['nginx'].to_hash.merge({
    :gitlab_http_config => File.join(nginx_etc_dir, "gitlab-http.conf"),
    :examplecom_http_config => File.join(nginx_etc_dir, "examplecom-http.conf"),
    })

    将此添加到同一文件:
    template nginx_vars[:examplecom_http_config] do
    source "nginx-examplecom-http.conf.erb"
    owner "root"
    group "root"
    mode "0644"
    variables(nginx_vars.merge(
    {
    :fqdn => "example.com",
    :port => 80,
    }
    ))
    notifies :restart, 'service[nginx]' if OmnibusHelper.should_notify?("nginx")
    end

    然后在模板目录(/ opt / gitlab / embedded / cookbooks / gitlab / templates / default)中,创建nginx虚拟主机模板文件(nginx-examplecom-http.conf.erb)并将其添加到此处:
    server {
    listen <%= @listen_address %>:<%= @port %>;
    server_name <%= @fqdn %>;
    root /var/www/example.com;

    access_log <%= @log_directory %>/examplecom_access.log;
    error_log <%= @log_directory %>/examplecom_error.log;

    location /var/www/example.com {
    # serve static files from defined root folder;.
    # @gitlab is a named location for the upstream fallback, see below
    try_files $uri $uri/index.html $uri.html;
    }

    error_page 502 /502.html;
    }

    您必须在(/etc/gitlab/gitlab.rb)中设置 nginx ['redirect_http_to_https'] = false :
    external_url "https://gitlab.example.com"
    gitlab_rails['gitlab_email_from'] = "info@example.com"
    gitlab_rails['gitlab_support_email'] = "support@example.com"



    nginx['redirect_http_to_https'] = false
    nginx['ssl_certificate'] = "/etc/gitlab/ssl/ssl-unified.crt"
    nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/ssl.key"


    gitlab_rails['gitlab_default_projects_limit'] = 10

    添加 include <%= @examplecom_http_config%>; 到/opt/gitlab/embedded/cookbooks/gitlab/templates/default/nginx.conf.erb中:
    http {
    sendfile <%= @sendfile %>;
    tcp_nopush <%= @tcp_nopush %>;
    tcp_nodelay <%= @tcp_nodelay %>;

    keepalive_timeout <%= @keepalive_timeout %>;

    gzip <%= @gzip %>;
    gzip_http_version <%= @gzip_http_version %>;
    gzip_comp_level <%= @gzip_comp_level %>;
    gzip_proxied <%= @gzip_proxied %>;
    gzip_types <%= @gzip_types.join(' ') %>;

    include /opt/gitlab/embedded/conf/mime.types;

    include <%= @gitlab_http_config %>;
    include <%= @examplecom_http_config %>;
    }

    在所有这些更改运行之后:
    gitlab-ctl reconfigure
    gitlab-ctl restart

    关于nginx - 使用gitlab的Nginx服务另一个应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24090624/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com