2017-04-13 152 views
0

我試圖按照https://docs.gitlab.com/omnibus/gitlab-mattermost/README.html配置Gitlab Mattermost。我正在使用非捆綁的nginx服務器,該服務器按照here所述進行配置。其餘的Gitlab目前正在工作;我可以通過訪問http://code.my.company.com來訪問它。Gitlab Mattermost的nginx服務器配置(使用非捆綁的nginx服務器)

Mattermost可能配置正確,但我似乎無法找到任何有關如何使用Mattermost配置非綁定nginx的信息。特別是,我想知道proxy_pass應該是什麼。

Gitlab sample configuration file使用proxy_pass http://gitlab-workhorse。在同一文件的頂部附近,他們將其定義爲unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket。這對Gitlab本身很有效(正如我們所希望的那樣),但我不知道012-用於Mattermost。

正如你在下面的nginx配置文件中看到的,我通過簡單地複製/粘貼大部分正常的Gitlab nginx配置文件(包括proxy_pass http://gitlab-workhorse行)創建了nginx配置文件的Mattermost部分。毫不奇怪,這只是導致http://code.my.company.com:1337轉發到正常的Gitlab,而不是Mattermost。

這裏是我的/etc/nginx/sites-available/default文件(該文件中所有的評論都是我的;如果你想看到原來的意見,看the source):

## Most of this is copy/pasted from https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/support/nginx/gitlab 
## A few of the paths are different from the current version, 
## perhaps because the Gitlab-suggested nginx config was different when I installed Gitlab 

upstream gitlab-workhorse { 
    server unix:/var/opt/gitlab/gitlab-workhorse/socket; 
} 

map $http_upgrade $connection_upgrade_gitlab { 
    default upgrade; 
    '' close; 
} 

## Mattermost config, mostly copy/pasted from the server{} block below 
server { 
    listen 0.0.0.0:1337 default_server; 
    listen [::]:1337 default_server; 
    server_name code.my.company.com; 

    location/{ 
    client_max_body_size 0; 
    gzip off; 

    proxy_read_timeout  300; 
    proxy_connect_timeout 300; 
    proxy_redirect   off; 

    proxy_http_version 1.1; 

    proxy_set_header Host    $http_host; 
    proxy_set_header X-Real-IP   $remote_addr; 
    proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for; 
    proxy_set_header X-Forwarded-Proto $scheme; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection $connection_upgrade_gitlab; 

    proxy_pass http://gitlab-workhorse; 
    } 

} 

## normal Gitlab config 
server { 
    listen 0.0.0.0:80 default_server; 
    listen [::]:80 default_server; 
    server_name code.my.company.com; 
    server_tokens off; 
    root /opt/gitlab/embedded/service/gitlab-rails/public; 

    access_log /var/log/nginx/gitlab_access.log; 
    error_log /var/log/nginx/gitlab_error.log; 


    location/{ 
    client_max_body_size 0; 
    gzip off; 

    proxy_read_timeout  300; 
    proxy_connect_timeout 300; 
    proxy_redirect   off; 

    proxy_http_version 1.1; 

    proxy_set_header Host    $http_host; 
    proxy_set_header X-Real-IP   $remote_addr; 
    proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for; 
    proxy_set_header X-Forwarded-Proto $scheme; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection $connection_upgrade_gitlab; 

    proxy_pass http://gitlab-workhorse; 
    } 
} 

這裏是/etc/gitlab/gitlab.rb相關部分:

external_url 'http://code.my.company.com' 
mattermost_external_url 'http://code.my.company.com:1337' 

nginx['enable'] = false 
mattermost_nginx['enable'] = false 

mattermost['gitlab_enable'] = true 
mattermost['gitlab_id'] = "HiddenForStackOverflowPost" 
mattermost['gitlab_secret'] = "HiddenForStackOverflowPost" 
mattermost['gitlab_scope'] = "" 
mattermost['gitlab_auth_endpoint'] = "http://code.my.company.com/oauth/authorize" 
mattermost['gitlab_token_endpoint'] = "http://code.my.company.com/oauth/token" 
mattermost['gitlab_user_api_endpoint'] = "http://code.my.company.com/api/v3/user" 

回答

1

下面是一個什麼樣的工作Mattermost nginx的配置看起來像docs一個例子:

upstream backend { 
    server 10.10.10.2:8065; 
} 

proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=mattermost_cache:10m max_size=3g inactive=120m use_temp_path=off; 

server { 
    listen 80; 
    server_name mattermost.example.com; 

    location /api/v3/users/websocket { 
     proxy_set_header Upgrade $http_upgrade; 
     proxy_set_header Connection "upgrade"; 
     client_max_body_size 50M; 
     proxy_set_header Host $http_host; 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header X-Forwarded-Proto $scheme; 
     proxy_set_header X-Frame-Options SAMEORIGIN; 
     proxy_buffers 256 16k; 
     proxy_buffer_size 16k; 
     proxy_read_timeout 600s; 
     proxy_pass http://backend; 
    } 

    location/{ 
     client_max_body_size 50M; 
     proxy_set_header Connection ""; 
     proxy_set_header Host $http_host; 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header X-Forwarded-Proto $scheme; 
     proxy_set_header X-Frame-Options SAMEORIGIN; 
     proxy_buffers 256 16k; 
     proxy_buffer_size 16k; 
     proxy_read_timeout 600s; 
     proxy_cache mattermost_cache; 
     proxy_cache_revalidate on; 
     proxy_cache_min_uses 2; 
     proxy_cache_use_stale timeout; 
     proxy_cache_lock on; 
     proxy_pass http://backend; 
    } 
} 

您需要用運行Mattermost的IP(或主機)和端口替換10.0.0.2:8065。如果您也想設置SSL,請查看文檔here(此示例配置取自此處)。

+0

下面是我所做的:在'/ var/opt/gitlab/mattermost/config.json'中,我發現''ServiceSettings「。」ListenAddress「'爲'」127.0.0.1:8065「'。我運行'捲曲127.0.0.1:8065'來測試它,並且工作 - 我得到了mattermost主頁html。正如你所推薦的那樣,我在配置中使用了這個IP - 上游後端{server 127.0.0.1:8065; }' 它工作!謝謝!! – pianoJames