RewriteEngine on

RewriteRule ^/v2/latest/(.*) /v2/f27/$1 [R,L]

{% if env == "staging" %}
RewriteRule ^/v2/(.*) /v2/centos/$1
{% endif %}

RewriteRule ^/signatures/(.*) /srv/web/registry-signatures/$1 [L]

<Directory /srv/web/registry-signatures>
    Require all granted
</Directory>

{% include './reversepassproxy.registry-generic.conf' %}

# Write access to docker-deployer only
{% if env == "staging" %}
  <Location /v2/centos>
    <LimitExcept GET HEAD>
      Require user docker-registry-internal-stg
    </LimitExcept>
  </Location>
  <Location /v2/fedora>
    Require all denied
  </Location>

{% else %}

  <Location /v2>
    require valid-user
  </Location>
{% endif %}
