Supports dynamic thumbnails images sizes processing + caching results, simple to use.
Awesome!!!
server { | |
server_name img.l; | |
root /var/www/cache/store/ns365; | |
index index.html; | |
# This requests the original file from itself and then resizes the image. | |
location ~ /resize/(\d+)x(\d+)/(.*) { | |
proxy_pass http://img.l/$3; | |
image_filter resize $1 $2; | |
image_filter_jpeg_quality 90; | |
image_filter_buffer 10M; | |
# Do not call this directly because the resized image is NOT cached. | |
allow 127.0.0.0/8; | |
deny all; | |
} | |
# Access denied. | |
location /resize { | |
return 403; | |
} | |
# RESIZED: http://img.l/200x200/files/2013/03/March_11_2013_ML.jpg | |
location ~ /(\d+x\d+/.*) { | |
try_files /$1 @img; | |
} | |
# ORIGINAL: http://img.l/files/2013/03/March_11_2013_ML.jpg | |
location / { | |
# If we don't find the file locally download it. | |
error_page 404 = @proxy; | |
} | |
# This saves the resized image locally. | |
location @img { | |
proxy_pass http://img.l/resize$uri; | |
proxy_store /var/www/cache/store/ns365$uri; | |
} | |
# This gets the remote image and saves it locally. | |
location @proxy { | |
proxy_pass http://example.com$uri; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_store /var/www/cache/store/ns365$uri; | |
} | |
} |