Welcome! Log In Create A New Profile

Advanced

nginx rewrite for cached images

May 04, 2012 03:20AM
Hi there,

we are currently migratiing all services from apache2 to nginx but are
currently stuck with a specific rewrite rule.
The rule in apache is checking if a cached image/thumbnail exists and if
so, delivers the output directly.
otherwise it will rewrite the request to an image-processor.

# if cached version exists, output directly
RewriteCond %{QUERY_STRING} ^(Guest|Member|avatar|tagged|thumb)$
RewriteCond %{DOCUMENT_ROOT}/cache/$1/%{QUERY_STRING}.jpg -f
RewriteRule (.*)\.jpg$ /cache/$1/%{QUERY_STRING}.jpg [L]

# otherwise redirect all jpg-image-requests to processing
# script if they are not in cache dir
RewriteCond %{REQUEST_URI} !^/cache
RewriteRule \.jpg$ /image_processing.php [QSA,L]

we tried several try_files approaches but we failed so far.
could someone please help in migrating this rewrite rules to nginx?

Thank you very much!


--

Andreas Lehr
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

nginx rewrite for cached images

shakalandy May 04, 2012 03:20AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 178
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready