I am having trouble getting Imagecache working using Nginx as my server. I have narrowed down my issue to the URL that is being provided for the image. I have added the rewrite rule from this post (http://drupal.org/node/385690#comment-1360524), and it helps if the correct URL is used to access the image.
The non-working URL in the page source for the image is:
http://example.com/system/files/imagecache/product_full/Image.jpg
Working URLs:
http://example.com/sites/default/files/imagecache/product_full/Image.jpg (This URL doesn't work without the Rewrite rule I mentioned.)
http://example.com/index.php?q=system/files/imagecache/product_full/Imag...
Why would my rewrite rule that works for every other page on my site not work for the image cache directory? This is the main rewrite rule:
location / {
root /var/www/html/example.com;
index index.php;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
break;
}
}
EDIT: I figured out that the rewrite rule to serve images and css directly (http://drupal.org/node/110224#comment-772191) was causing imagecache to be bypassed entirely. Removing this rule allows imagecache to process the images and they also display appropriately. I do not know of any issues this may cause but will keep an eye on it.
Comments
I think you need something
I think you need something like this... The important bit for you it the bit tagged with the line '# imagecache needs to have php read any files that it's planning to manipulate'. And, if you are not using a multisite set up, as I am, you will need alter some of the urls, including the path to your ImageCache directory.
--
Tom
www.systemseed.com - drupal development. drupal training. drupal support.
You are correct. Without
You are correct. Without that section imagecache does not work.
However, the serve static files directly rule was causing the server to look for the file at the exact URL bypassing Drupal.
www.example.com/system/files/imagecache/preset_name/Image.jpg
My site is setup using the private file system. This means that requests for files must be passed through Drupal. Drupal expects a URL like this for every request:
www.example.com/index.php?q=system/files/imagecache/preset_name/Image.jpg
This would require the Imagecache URL to be rewritten so that index.php?q= can be inserted to pass the request through Drupal. However, the serve static files directly rule was causing nginx to bypass the rewrite and look for the file on the server without going through Drupal.
Removing that rule allows the URL to be rewritten and routes the request for the image through Drupal.
With the setup I outlined
With the setup I outlined above, you don't need to remove that rule. Because, the location directive I assigned to the ImageCache URL has a higher priority that the one for static files, allowing you to serve static files directly AND send ImageCache URL's through Drupal.
EDIT:
so, for ImageCache on a private filesystem, you could try setting:
And Nginx should take that location directive over the static one due the the use of ^~
--
Tom
www.systemseed.com - drupal development. drupal training. drupal support.
I'm having the same
I'm having the same problem... but I get this error if I try to see an imagecache image url.
"Firefox has detected that the server is redirecting the request for this address in a way that will never complete."
solved by putting
solved by putting this:
Also I recommend this
http://www.webinit.org/2009/08/15/nginx-drupal-visited/
This doesn't really count
This doesn't really count because you are now passing it onto Apache- so this will work for you, but it won't work for anybody using nginx + php_fastcgi!
Webmaster @ WikiJob Graduate Jobs
This is the right way to do
This is the right way to do it:
Put in your vhost config.
Hope that helps :)
missing '@rewrite' location
cmayo, there is a missing '@rewrite' location in your example..