# Copyright 2025-2026 Thomas Hintz

# This file is part of Nassella.

# Nassella is free software: you can redistribute it and/or modify it under the
# terms of the GNU Affero General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.

# Nassella is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with Nassella. If not, see <https://www.gnu.org/licenses/>.

{$nassella_SUBDOMAIN}.{$ROOT_DOMAIN} {
  import maintenance_intercept

  route {
    @authelia path /authelia /authelia/*
    handle @authelia {
      reverse_proxy nassella_authelia:9091
    }

    handle /unsecured/* {
      reverse_proxy http://nassella:8080
    }

    forward_auth nassella_authelia:9091 {
      uri /api/authz/forward-auth
      copy_headers Remote-User Remote-Groups Remote-Email Remote-Name
    }

    reverse_proxy http://nassella:8080
  }
}

lldap.{$nassella_SUBDOMAIN}.{$ROOT_DOMAIN} {
  import maintenance_intercept
  reverse_proxy nassella_lldap:17170
}
