Search code examples
nginxgitlabgitlab-omnibusmattermost

400 Bad Request in GitLab's Mattermost


GitLab 8.9.4 running fine (Omnibus) in an Ubuntu Server 16.04 virtual machine through port 802: external_url 'http://gitlab_url:802'

I've enabled Mattermost by this line in /etc/gitlab/gitlab.rb:
mattermost_external_url 'http://gitlab_url:8065'

I've also opened the port 8065 in my router. But this is what I get when I try to access that gitlab_url:8065 in a browser:

400 Bad Request
Request Header Or Cookie Too Large
nginx

In the guide, I skipped the "Running GitLab Mattermost on its own server" part because it would be fine for me with the embedded version if I could make it work.

Reading the "Manually (re)authorising GitLab Mattermost with GitLab" part, I went to the Applications section in the Admin Area, and I found a "Mattermost" application. The two urls there were wrong (probably because the first time I set a dummy mattermost_external_url), so I manually corrected them. I'm not sure if I tried with/without the port or both.

I tried to remove Mattermost Application in GitLab and start again Mattermost configuration. I also tried to reset Mattermost (doing this) but I always get to the same error.

I also tried to set this in /etc/gitlab/gitlab.rb:

mattermost['gitlab_enable'] = true
mattermost['gitlab_secret'] = "***"
mattermost['gitlab_id'] = "***"
mattermost['gitlab_scope'] = ""
mattermost['gitlab_auth_endpoint'] = "http://gitlab_url:8065/oauth/authorize"
mattermost['gitlab_token_endpoint'] = "http://gitlab_url:8065/oauth/token"
mattermost['gitlab_user_api_endpoint'] = "http://gitlab_url:8065/api/v3/user"

I enabled the log:
mattermost['log_file_directory'] = '/var/log/gitlab/mattermost'

And cat /var/log/gitlab/mattermost/mattermost.log basically tells me:

Automatic database upgrade failed.!!!

But this is the first time I try to set up Mattermost!

Also note everytime I run sudo gitlab-ctl reconfigure (and I called it after every modification) I get a laaarge output.

(I posted the same question here)


Solution

  • DJ Mountney gave the answer here:

    The Mattermost service runs by default on port 8065 (behind nginx), the mattermost external url setting is telling nginx what port to listen on for mattermost.

    If you set the two to the same port, only one will get it. In your case it was nginx, if you run sudo gitlab-ctl tail mattermost you will likely see that it has failed to bind to the port.

    If you change the mattermost_external_url to a different port, it should start working.

    Indeed, changing mattermost port solves it. Ie:

    mattermost_external_url 'http://gitlab_url:8066'
    

    Also note gitlab_auth_endpoint, gitlab_token_endpoint and gitlab_user_api_endpoint urls should point to the gitlab application + port (802 in my case, not 8066):

    mattermost['gitlab_auth_endpoint'] = "http://gitlab_url:802/oauth/authorize"
    mattermost['gitlab_token_endpoint'] = "http://gitlab_url:802/oauth/token"
    mattermost['gitlab_user_api_endpoint'] = "http://gitlab_url:802/api/v3/user"