Search code examples
herokuhttpsimagemagickpolicynode-imagemagick

Imagemagick - change policy.xml on Heroku


I'm trying to access images via https on Heroku with Imagemagick. How can I change the policies (in policy.xml) on Heroku?

Heroku made an "ImageMagick security update" in May, 2016: https://devcenter.heroku.com/changelog-items/891

I can see the policy list, after typing heroku run bash and convert -list policy:

Path: [built-in] Policy: Undefined rights: None

Path: /etc/ImageMagick/policy.xml [...] Policy: Coder rights: None pattern: HTTPS [...]

How can I change the policy?

update 1: this is the error in the log file:

Command failed: convert.im6: not authorized `//scontent-fra3-1.xx.fbcdn.net/v/t1.0-9/13962741_132344500547278_4974691444630710043_n.jpg?oh=c169b4ffce9e5ce330ee99214cc6b8d5&oe=5880F245'


Solution

  • I’ve found a relatively simple solution.

    Create a .magick directory in your app’s source, and add your policy.xml there. Then, you’ll have to set the environment variable MAGICK_CONFIGURE_PATH to /app/.magick in order to load your file with higher precedence than the default one.