January 31, 2013

Image cache issue in drupal with nginx


Resolved it by adding the following in nginx virtual host file:
       
    location ^~ /sites/default/files/imagecache/ {
            index  index.php index.html;

            if (!-e $request_filename) {
                rewrite  ^/(.*)$  /index.php?q=$1  last;
                break;
            }
        }

The above assumes that your imagecache files are to be stored in sites/default/files/imagecache
Instead of nginx serving the static content (the jpeg or png or whatever) to the browser it will instead rewrite the path to (invisibly): index.php?q=sites/default/files...
This allows imagecache to run its manipulations on the file.
Just make sure you alter the location directive to match whatever path your imagecache files are in (relative to site root) and you should be fine.

Reference:

No comments:

Post a Comment