Skip to content

Instantly share code, notes, and snippets.

@antevens
Last active December 14, 2019 01:43
Show Gist options
  • Save antevens/458e6723ea3d09dd544ac8cb5d9111ac to your computer and use it in GitHub Desktop.
Save antevens/458e6723ea3d09dd544ac8cb5d9111ac to your computer and use it in GitHub Desktop.
Create a script, this can easily be ported/re-written, I used /usr/local/bin/get_real_filename
#!/bin/bash
while read line ; do
abs_path="$(readlink "${line}")"
echo "processing ${line}" >> /tmp/log
if [ -n "${abs_path}" ] ; then
stdbuf --output=0 echo "$(basename "${abs_path}")"
else
stdbuf --output=0 echo 'NULL'
fi
done
sudo chmod 755 "/usr/local/bin/get_real_filename"
sudo chown root:root "/usr/local/bin/get_real_filename"
# In every virtualhost, (443 and 5000) add these lines around the top part:
# Set up rewrite map to look up real file names for sha256 sums for Docker-Content-Digest
RewriteEngine On
RewriteMap symlink "prg:/usr/local/bin/get_real_filename" apache:apache
# In pulp_docker.conf Under <Directory /var/www/pub/docker/v2/web/*/manifests/2>, around the other Headers
RewriteCond %{REQUEST_FILENAME} -l
RewriteCond ${symlink:%{REQUEST_FILENAME}} "(.+)"
RewriteRule "(.*)" - [E=DIGEST:%1]
Header set Docker-Content-Digest "%{DIGEST}e"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment