# {{ ansible_managed }}

Listen {{ tripleo_container_registry_port }}
<VirtualHost {{ tripleo_container_registry_host }}:{{ tripleo_container_registry_port }}>
    DocumentRoot {{ tripleo_image_data_dir }}
    ErrorLog "/var/log/httpd/image_serve_error.log"
    ServerSignature Off
    CustomLog "/var/log/httpd/image_serve_access.log" combined
    SetEnvIf X-Forwarded-Proto https HTTPS=1
    RedirectMatch ^/$ /v2
    TraceEnable off

    <Directory {{ tripleo_image_data_dir }}>
        # This assumes a file exists containing {} at
        # {{ tripleo_image_data_dir }}/index.json
        DirectoryIndex index.json

        Options FollowSymLinks MultiViews
        AllowOverride FileInfo
        Require all granted

        Header set Docker-Distribution-Api-Version registry/2.0
    </Directory>

    # LP#1953198 / rhbz#2026654
    <LocationMatch "^/v2/.*/.*/manifests/(?!sha256:).*$">
        Options FollowSymLinks
        AllowOverride None
        AddHandler type-map .type-map
        RewriteEngine On
        ReWriteCond %{REQUEST_URI} !(\.json|\.type-map)$
        RewriteRule ^(.*) $1.type-map [PT,L]
    </LocationMatch>

    <LocationMatch "^/v2/.*/manifests/(?!sha256:).*$">
        Options FollowSymLinks
        AllowOverride None
        AddHandler type-map .type-map
        RewriteEngine On
        ReWriteCond %{REQUEST_URI} !(\.json|\.type-map)$
        RewriteRule ^(.*) $1.type-map [PT,L]
    </LocationMatch>

    <LocationMatch "^/v2/.*/.*/blobs/sha256:.*$">
        SetEnvIf Request_URI "sha256:(.*)$" digest=sha256:$1
        Header set Docker-Content-Digest "%{digest}e"
        Header set ETag "%{digest}e"
        Header set Cache-Control "max-age=31536000"
        Header set Content-Type "application/octet-stream"
    </LocationMatch>

    <LocationMatch "^/v2/.*/blobs/sha256:.*$">
        SetEnvIf Request_URI "sha256:(.*)$" digest=sha256:$1
        Header set Docker-Content-Digest "%{digest}e"
        Header set ETag "%{digest}e"
        Header set Cache-Control "max-age=31536000"
        Header set Content-Type "application/octet-stream"
    </LocationMatch>


</VirtualHost>
