Posted by Tim Jones Toronto on May 10, 2012 at 8:52pm
Hello, I am investigating a problem using Nginx with imagecache.
I have described the problem in the Imagecache issue queue http://drupal.org/node/615418#comment-5981692
In a nutshell, Imagecache is not renaming files correctly on i) file upload and ii) using the Media module for accepting Youtube links. One suggestion is using a Rewrite rule for 'B' (escape backreferences) if using Apache (reported as working). However we are using Nginx.
I am using perusio https://github.com/perusio/drupal-with-nginx config with Drupal 7.14 for testing.
Any feedback on this would be great.
Comments
Posted fix on the issue queue
Replied here: http://drupal.org/node/615418#comment-5986966 and also here for further reference:
Well you have two options, either you go back to good'ol rewrite (it's uuugly) or you move along and beyond ;) and use Lua.
I'll update my config tomorrow. Someone else complained about a similar issue of more generic filenames on the issue queue.
To get a quick fix for your problem do on the imagecache location:
location ~* /imagecache/ {
## Image hotlinking protection. If you want hotlinking
## protection for your images uncomment the following line.
#include sites-available/hotlinking_protection.conf;
access_log off;
expires 30d;
## Fixes the fact that Nginx does exact matching. Escape happens on rewrite or
## regex location matching. All URI is escaped now.
set_by_lua $no_slash_escaped_uri
'return ngx.escape_uri(ngx.var.no_slash_uri)';
## Replace all vars by the escaped version.
try_files /$no_slash_escaped_uri /index.php?q=$no_slash_escaped_uri&$args;
}
Ar...right D7
Here's the fix for images in D7:
location ~* /files/styles/ {
## Image hotlinking protection. If you want hotlinking
## protection for your images uncomment the following line.
#include sites-available/hotlinking_protection.conf;
access_log off;
expires 30d;
## Fixes the fact that Nginx does exact matching. Escape happens on rewrite or
## regex location matching. All URI is escaped now.
set_by_lua $escaped_uri 'return ngx.escape_uri(ngx.var.uri)';
## Replace all vars by the escaped version.
try_files $escaped_uri /index.php?q=$escaped_uri&$args;
}
Support for escaped URIs
is commited.