I have now set it up as follows and it seems to work.
Callback URL: /users/auth/Mailcow/callback
gitlab_rails['omniauth_providers'] = [
{
"name" => "oauth2_generic",
"app_id" => "HIDDEN",
"app_secret" => "HIDDEN",
'args' => {
client_options: {
'site' => 'https://DOMAIN', # including port if necessary
'user_info_url' => '/oauth/profile'
},
name: 'Mailcow'
}
}
]