diff --git a/filter_plugins/utils.py b/filter_plugins/utils.py index e884b70..f91cdd8 100644 --- a/filter_plugins/utils.py +++ b/filter_plugins/utils.py @@ -14,6 +14,7 @@ def filters(self): "join_w_excludes": self.join_w_excludes, "waf_coraza_apps": self.waf_coraza_apps, "all_route_backends_exist": self.all_route_backends_exist, + "domains_not_routed": self.domains_not_routed, } @staticmethod @@ -206,3 +207,15 @@ def all_route_backends_exist(cls, cnf: dict) -> bool: return False return True + + @classmethod + def domains_not_routed(cls, fe_domains: list, routes: dict) -> list: + be_domains = [] + + for cnf in routes.values(): + if 'domains' not in cnf: + continue + + be_domains.extend(cls.ensure_list(cnf['domains'])) + + return [d for d in cls.ensure_list(fe_domains) if d not in be_domains] diff --git a/templates/etc/dehydrated/domains.txt.j2 b/templates/etc/dehydrated/domains.txt.j2 index 337193b..d69497e 100644 --- a/templates/etc/dehydrated/domains.txt.j2 +++ b/templates/etc/dehydrated/domains.txt.j2 @@ -9,7 +9,7 @@ {% set fe_cnf = defaults_frontend | combine(fe_cnf_user, recursive=true) %} # FRONTEND: {{ fe_name }} {% if fe_cnf.acme.domains | default([]) | ensure_list | length > 0 %} -{{ fe_cnf.acme.domains | default([]) | ensure_list | join(' ') }} > {{ fe_name | safe_key }} +{{ fe_cnf.acme.domains | default([]) | domains_not_routed(fe_cnf.routes) | join(' ') }} > {{ fe_name | safe_key }} {% endif %} {% for be_name, be_cnf_user in fe_cnf.routes.items() %} {% set be_cnf = defaults_backend | combine(be_cnf_user, recursive=true) %}