# Token Request Error on Omnibus with Reverse Proxy

**URL:** <https://forum.mattermost.com/t/token-request-error-on-omnibus-with-reverse-proxy/2746>\
**Category:** Troubleshooting\
**Created:** [January 13, 2017, 8:02pm UTC](https://forum.mattermost.com/t/token-request-error-on-omnibus-with-reverse-proxy/2746 "2017-01-13T20:02:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CalebEverett](https://avatars.discourse-cdn.com/v4/letter/c/779978/32.png) [@CalebEverett](https://forum.mattermost.com/u/CalebEverett)\
**Post date:** [January 13, 2017, 8:02pm UTC](https://forum.mattermost.com/t/token-request-error-on-omnibus-with-reverse-proxy/2746/1 "2017-01-13T20:02:32Z")

</div>

I am trying to get SSO for mattermost from gitlab working in the Omnibus installation. Any ideas on how to troubleshoot would be greatly appreciated.

### Setup

I have the Omnibus package installed in an lxc container running Ubuntu 16.04 with traffic from the internet routed through nginx running in another container. I’m terminating the ssl connections in the nginx container where the certs are, and then forwarding traffic to the gitlab lxc container via server configurations for each of my gitlab and mattermost urls.

### The Problem

When I click the sign in with gitlab button it takes me to the authorization url, but then when I click authorize, I get:

```auto
Token request failed

```

and in `/var/log/gitlab/mattermost/mattermost.log`, I get:

`[2017/01/13 22:36:08 UTC] [EROR] websocket connect err: websocket: could not find connection header with token 'upgrade' [2017/01/13 22:36:08 UTC] [EROR] /api/v3/users/websocket:connect code=500 rid=ojqur6wyubybmqyhegpptbmwey uid= ip=76.90.41.133, 10.29.248.10 Failed to upgrade websocket connection [details:] [2017/01/13 22:37:28 UTC] [EROR] SMTP server settings do not appear to be configured properly err=Failed to open connection details=dial tcp :0: getsockopt: connection refused [2017/01/13 22:37:45 UTC] [EROR] /signup/gitlab/complete:AuthorizeOAuthUser code=500 rid=i9eat3i7e7gjjpxddnp168oj9c uid= ip=76.90.41.133, 10.29.248.10 Token request failed [details: Post https://git.calebeverett.io:80/oauth/token: dial tcp 45.79.111.122:80: getsockopt: connection refused] `

What is odd to me is that initial request to `https://git.calebeverett.io/oauth/authorize` was successful.

### Configuration Settings

Here are the `mattermost-nginx` settings:

```auto
mattermost_nginx['listen_port'] = 8081
mattermost_nginx['listen_https'] = false
mattermost_nginx['proxy_set_headers'] = {
  "Host" => "$http_host",
  "X-Real-IP" => "$remote_addr",
  "X-Forwarded-For" => "$proxy_add_x_forwarded_for",
  "X-Frame-Options" => "SAMEORIGIN",
  "X-Forwarded-Proto" => "https",
  "X-Forwarded-Ssl" => "on",
  "Upgrade" => "$http_upgrade",
  "Connection" => "$connection_upgrade"
}

```

and here are the `nginx` settings:

```auto
nginx['listen_port'] = 80
nginx['listen_https'] = false
nginx['proxy_set_headers'] = {
 "X-Forwarded-Proto" => "https",
 "X-Forwarded-Ssl" => "on",
}

```

### Resources

#### Documentation

[Gitlab-Mattermost Docs](https://docs.gitlab.com/omnibus/gitlab-mattermost/)  
[SSO documentation](https://docs.mattermost.com/deployment/sso-gitlab.html)

#### Other Posts

> [@Bad response from token request after team creation auth](http://forum.mattermost.com/t/bad-response-from-token-request-after-team-creation-auth/895):
>
> Hi Guys, I can’t create a team in a gitlab-mattermost environnement. After authorisation from gitlab SSO i got redirected to the /signup/gitlab/complete and results in a 500 error : Bad response from token request. i don’t use https / certificates, just plain http. I enabled error logging but i don’t have the error details shown. I’am using apache on plesk, and gitlab works perfectly /var/log/gitlab/mattermost/mattermost.log: [2016/02/14 20:18:42 CET] [DEBG] /signup/gitlab/complete [2016/0…

> [@\[SOLVED\] Mattermost Gitlab - Token request failed](http://forum.mattermost.com/t/solved-mattermost-gitlab-token-request-failed/2628):
>
> Summary Getting the message “Token request failed” when i try to authorize mattermost on gitlab. Steps to reproduce I followed the [gitlab mattermost install page](https://docs.gitlab.com/omnibus/gitlab-mattermost/), i’m runing the whole gitlab environment in dockers (using [official image](https://hub.docker.com/r/gitlab/gitlab-ce/)) Expected behavior Describe your issue in detail Observed behavior Once i try to login on my mattermost env through gitlab, It keep telling my that the Token registration as been rejected. Mattermost login page [httpsgyazo.com/f8b8bf58882361f07ba8180b897ad92…](http://httpsgyazo.com/f8b8bf58882361f07ba8180b897ad928)

> [@"Token request failed" error on GitLab Mattermost](http://forum.mattermost.com/t/token-request-failed-error-on-gitlab-mattermost/730):
>
> Mattermost and Gitlab are latest Gitlab is port 8181, Mattermost is port 8282, both are https. They are running on same server, Gitlab Omnibus package. I followed the steps from guide url below Go to mattermost home page Add a team name Click on create Redirects to gitlab login page After login it shows "Authorize required, Authorize mattermost to use your account? I click accept Redirects to mattermost it shows “GitLab Mattermost needs your help: Token request failed, Go back to te…

> [@Mattermost with Gitlab SSO ignores https scheme when creating implicit token request](http://forum.mattermost.com/t/mattermost-with-gitlab-sso-ignores-https-scheme-when-creating-implicit-token-request/249):
>
> Hi there, First of all thank you for creating this project and I’m even more stoked that it integrates with Gitlab making it much easier to get it adopted in the organisation that’s already using Gitlab. Now my frontend servers use HSTS header so all things that run off them, run on https off a wildcard certificate. I’ve used your draft notes to configure mattermost (0.7.1 precompiled binary) with Gitlab SSO and it’s working a treat. The only hitch that I noticed was that when mattermost call…

---

<div class="post-metadata">

**Author:** ![jasonblais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/jasonblais/32/720_2.png) [@jasonblais](https://forum.mattermost.com/u/jasonblais)\
**Post date:** [February 3, 2017, 1:02pm UTC](https://forum.mattermost.com/t/token-request-error-on-omnibus-with-reverse-proxy/2746/2 "2017-02-03T13:02:05Z")

</div>

Hey @CalebEverett and really, really sorry for the slow response.

Looks like this might be an error on GitLab Omnibus, can you help cross-post your note in the GitLab troubleshooting forums?

> **[Troubleshooting](https://forum.gitlab.com/c/troubleshooting)**
>
> Post here any issues you may have installing, configuring or running GitLab. If you are not sure if you hit a bug this is the right place to do it.

They’ll have more expertise on how to resolve it.

---

<div class="post-metadata">

**Author:** ![lnxm8](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@lnxm8](https://forum.mattermost.com/u/lnxm8)\
**Post date:** [June 26, 2018, 7:11pm UTC](https://forum.mattermost.com/t/token-request-error-on-omnibus-with-reverse-proxy/2746/3 "2018-06-26T19:11:08Z")

</div>

I know it’s been a while, but was this ever resolved? I’m having exactly the same issue.

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [June 26, 2018, 11:41pm UTC](https://forum.mattermost.com/t/token-request-error-on-omnibus-with-reverse-proxy/2746/4 "2018-06-26T23:41:42Z")

</div>

Hi @lnxm8 - thank you for your question! Looks like this was/is an issue on Gitlab’s side, so you might want to check with Gitlab on this and/or look if an issue related to this was opened in their troubleshooting forum that Jason linked above ^
