{#
SPDX-FileCopyrightText: 2024 Slavi Pantaleev

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{% if matrix_bridge_mautrix_meta_instagram_container_labels_traefik_enabled and matrix_bridge_mautrix_meta_instagram_container_labels_exposure_enabled %}
traefik.enable=true

{% if matrix_bridge_mautrix_meta_instagram_container_labels_traefik_docker_network %}
traefik.docker.network={{ matrix_bridge_mautrix_meta_instagram_container_labels_traefik_docker_network }}
{% endif %}

{% if matrix_bridge_mautrix_meta_instagram_container_labels_exposure_enabled %}
traefik.http.services.{{ matrix_bridge_mautrix_meta_instagram_identifier }}-appservice.loadbalancer.server.port=29319
{% endif %}

{% if matrix_bridge_mautrix_meta_instagram_container_labels_exposure_enabled %}
############################################################
#                                                          #
# Bridge API exposure                                      #
#                                                          #
############################################################

traefik.http.middlewares.{{ matrix_bridge_mautrix_meta_instagram_identifier }}-exposure-strip-prefix.stripprefix.prefixes={{ matrix_bridge_mautrix_meta_instagram_exposure_path_prefix }}
traefik.http.routers.{{ matrix_bridge_mautrix_meta_instagram_identifier }}-exposure.middlewares={{ matrix_bridge_mautrix_meta_instagram_identifier }}-exposure-strip-prefix

traefik.http.routers.{{ matrix_bridge_mautrix_meta_instagram_identifier }}-exposure.rule={{ matrix_bridge_mautrix_meta_instagram_container_labels_exposure_traefik_rule }}

{% if matrix_bridge_mautrix_meta_instagram_container_labels_exposure_traefik_priority | int > 0 %}
traefik.http.routers.{{ matrix_bridge_mautrix_meta_instagram_identifier }}-exposure.priority={{ matrix_bridge_mautrix_meta_instagram_container_labels_exposure_traefik_priority }}
{% endif %}

traefik.http.routers.{{ matrix_bridge_mautrix_meta_instagram_identifier }}-exposure.service={{ matrix_bridge_mautrix_meta_instagram_identifier }}-appservice
traefik.http.routers.{{ matrix_bridge_mautrix_meta_instagram_identifier }}-exposure.entrypoints={{ matrix_bridge_mautrix_meta_instagram_container_labels_exposure_traefik_entrypoints }}

traefik.http.routers.{{ matrix_bridge_mautrix_meta_instagram_identifier }}-exposure.tls={{ matrix_bridge_mautrix_meta_instagram_container_labels_exposure_traefik_tls | to_json }}
{% if matrix_bridge_mautrix_meta_instagram_container_labels_exposure_traefik_tls %}
traefik.http.routers.{{ matrix_bridge_mautrix_meta_instagram_identifier }}-exposure.tls.certResolver={{ matrix_bridge_mautrix_meta_instagram_container_labels_exposure_traefik_tls_certResolver }}
{% endif %}

############################################################
#                                                          #
# /Bridge API exposure                                     #
#                                                          #
############################################################
{% endif %}

{% endif %}

{{ matrix_bridge_mautrix_meta_instagram_container_labels_additional_labels }}
