Crivaledaz / Mattermost-LDAP

This module provides an external LDAP authentication in Mattermost for the Team Edition (free).
MIT License
359 stars 71 forks source link

Apache 2.4 HTTPS Reverse Proxy Documentation Request #77

Open sempervictus opened 3 years ago

sempervictus commented 3 years ago

The documentation around reverse proxy configuration is a bit confusing, and i'm currently unable to get the setup working on a single host with mattermost using a valid LDAPS configuration (required the port number in the ldap_host variable) which i can use to authenticate if i simply access mattermost-LDAP directly. I've got the virtualhost for the ldap URL listening on localhost:12080 and mattermost bound on localhost:8065 with the apache reverse proxy listening on 443 and passing back and forth with mattermost. I've configured mattermost to treat its own https://fqdn as the gitlab server with the gitlab URI's configured under its own FQDN. The apache virtualhost current looks like:

<VirtualHost *:443>
    ServerName host.domain.tld

    ProxyPreserveHost On
    RewriteEngine On
    RewriteCond %{REQUEST_URI} /api/v[0-9]+/(users/)?websocket [NC,OR]
    RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC,OR]
    RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
    RewriteRule .* ws://127.0.0.1:8065%{REQUEST_URI} [P,QSA,L]

    <Location />
        Require all granted
        ProxyPass http://127.0.0.1:8065/
        ProxyPassReverse http://127.0.0.1:8065/
        ProxyPassReverseCookieDomain 127.0.0.1 svl-arch00.lab.hq.svit.local
    </Location>

    <Location /api/v4/user>
        Require all granted
        ProxyPass http://localhost:12080/resource.php
        ProxyPassReverse http://localhost:12080/resource.php
        ProxyPassReverseCookieDomain 127.0.0.1 <%= @hostname %>
    </Location>

    <Location /oauth/token>
        Require all granted
        ProxyPass http://localhost:12080/token.php
        ProxyPassReverse http://localhost:12080/token.php
        ProxyPassReverseCookieDomain 127.0.0.1 <%= @hostname %>
    </Location>

    <Location /oauth/authorize>
        Require all granted
        ProxyPass http://localhost:12080/authorize.php
        ProxyPassReverse http://localhost:12080/authorize.php
        ProxyPassReverseCookieDomain 127.0.0.1 <%= @hostname %>
    </Location>

Unfortunately this doesn't work as the link for "sign in with gitlab" points to https://host.domain.tld/oauth/gitlab/login and that goes nowhere (brings back to the main login page).

What's the right way to do this with mm and the ldap proxy set up on a single host with Apache? Thanks