Gitlab mattermost oauth problem

Hey guys,
I have gitlab and mattermost on a separate servers and can’t make gitlab oauth work with mattermost.
It redirects me to page with 404 error.

Here is the gitlab production.log

Started POST "/oauth/authorize" for 127.0.0.1 at 2016-05-07 21:51:24 +0400 Processing by Oauth::AuthorizationsController#create as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "client_id"=>"84c196d399b550d69ff147bb424a287f665768c6e4a6f6cd2f96cdf7815d9146", "redirect_uri"=>"http://url/signup/gitlab/complete", "state"=>"eyJhY3Rpb24iOiJzaWdudXAiLCJoYXNoIjoiJDJhJDEwJGFKdlp3Z3Bpdi5GdndtU1ZxSXhpdHVFMGV2SzhCbzBwVzVGeTJFQzhLSXVyQ21ZZU1KeWI2IiwidGVhbSI6InFhcnZhMDEyMzQ1Njc4OTEwMTExMjEzMTQxNTE2MTcxODE5MjAyMTIyMjMyNDI1MjYyNyJ9", "response_type"=>"code", "scope"=>"api", "commit"=>"Authorize"} Redirected to http://url/signup/gitlab/complete?code=2b47d406beec1cca4332a9611a148be53a3662f2e411392ae608642ee03c46e5&state=eyJhY3Rpb24iOiJzaWdudXAiLCJoYXNoIjoiJDJhJDEwJGFKdlp3Z3Bpdi5GdndtU1ZxSXhpdHVFMGV2SzhCbzBwVzVGeTJFQzhLSXVyQ21ZZU1KeWI2IiwidGVhbSI6InFhcnZhMDEyMzQ1Njc4OTEwMTExMjEzMTQxNTE2MTcxODE5MjAyMTIyMjMyNDI1MjYyNyJ9 Completed 302 Found in 77ms (ActiveRecord: 67.0ms) Started GET "/signup/gitlab/complete?code=[FILTERED]&state=eyJhY3Rpb24iOiJzaWdudXAiLCJoYXNoIjoiJDJhJDEwJGFKdlp3Z3Bpdi5GdndtU1ZxSXhpdHVFMGV2SzhCbzBwVzVGeTJFQzhLSXVyQ21ZZU1KeWI2IiwidGVhbSI6InFhcnZhMDEyMzQ1Njc4OTEwMTExMjEzMTQxNTE2MTcxODE5MjAyMTIyMjMyNDI1MjYyNyJ9" for 127.0.0.1 at 2016-05-07 21:51:24 +0400 Processing by NamespacesController#show as HTML Parameters: {"code"=>"[FILTERED]", "state"=>"eyJhY3Rpb24iOiJzaWdudXAiLCJoYXNoIjoiJDJhJDEwJGFKdlp3Z3Bpdi5GdndtU1ZxSXhpdHVFMGV2SzhCbzBwVzVGeTJFQzhLSXVyQ21ZZU1KeWI2IiwidGVhbSI6InFhcnZhMDEyMzQ1Njc4OTEwMTExMjEzMTQxNTE2MTcxODE5MjAyMTIyMjMyNDI1MjYyNyJ9", "id"=>"signup/gitlab/complete"} Completed 404 Not Found in 48ms (Views: 0.9ms | ActiveRecord: 2.4ms)

I made another instance of gitlab with mattermost and it works just fine, difference between logs can bee seen here.

https://www.diffchecker.com/uz4cds5r

For some reason Doorkeeper doesn’t seem to process the request and NamespacesController handles it instead. Can anybody help me with this ? or at least point me to a right direction.

thanks !