# Redirect links from Fedora Forge for Pagure attachments
SSLProxyEngine On
SSLProxyVerify require
SSLProxyVerifyDepth 2
SSLProxyCACertificateFile "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"
{% if env == "staging" %}
# We also define prod pagure on staging as we special-case some proxies to prod pagure
SSLProxyEngine On
SSLProxyVerify require
SSLProxyVerifyDepth 2
SSLProxyCACertificateFile "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"
# Special case for stg forgejo testdays-web to proxy to prod pagure
ProxyPassMatch ^.*?/fedora-qa/testdays-web/issue/raw/files/(.*)$ https://pagure.io/fedora-qa/testdays-web/issue/raw/files/$1
{% endif %}
# Forgejo can't decide whether to render root-relative links as relative
# to the server root or the repo root, and currently behaves differently
# for image and non-image links:
# https://codeberg.org/forgejo/forgejo/issues/6360#issuecomment-9010932
# This first match handles cases where the link is rendered relative to
# to repo. As all repos must have an org in Forgejo, if there are more
# than two directories before /issue, this must be repo-relative; the
# third match will be either pagurerepo or pagureorg/pagurerepo
ProxyPassMatch ^/(.+?)/(.+?)/(.+?)/issue/raw/files/(.*)$ https://{{ env_prefix }}pagure.io/$3/issue/raw/files/$4
# This match handles cases where the link is rendered relative to the
# server root; if we didn't hit the first match, the first match here
# will be pagurerepo or pagureorg/pagurerepo
ProxyPassMatch ^/(.+?)/issue/raw/files/(.*)$ https://{{ env_prefix }}pagure.io/$1/issue/raw/files/$2
{% include 'reversepassproxy.conf' %}