Skip to content

Instantly share code, notes, and snippets.

@jaromirnyklicek
Created May 17, 2015 20:50
Show Gist options
  • Save jaromirnyklicek/da2ad86dab30eb60b46b to your computer and use it in GitHub Desktop.
Save jaromirnyklicek/da2ad86dab30eb60b46b to your computer and use it in GitHub Desktop.
server {
error_log /var/log/nginx/skeletis-content.log;
rewrite_log on;
root /var/www/skeletis-content.cz;
index index.html;
server_name skeletis-content.cz skeletis-content.loc;
location ~* /(\d+)\.(jpg|jpeg|png|gif|bmp)/([a-z0-9]+)/(\d+)x(\d+) {
alias "/var/www/skeletis-content.cz";
set $id $1;
set $ext $2;
set $hash $3;
set $width $4;
set $height $5;
set $thumb_file "/$1/thumb_$4x$5.$2";
set $resize_url "resize?id=$id&ext=$ext&width=$width&height=$height";
set $hash_file "/$1/_$hash";
if (!-f $document_root$hash_file) {
return 401;
}
if (!-f $thumb_file) {
proxy_pass http://127.0.0.1/$resize_url;
break;
}
proxy_store $document_root$thumb_file;
proxy_store_access user:rw group:rw all:r;
proxy_temp_path /tmp/images;
proxy_set_header Host $host;
}
location /resize {
alias /var/www/skeletis-content.cz/$arg_id/_.$arg_ext;
image_filter resize $arg_width $arg_height;
image_filter_jpeg_quality 90;
allow 127.0.0.0/8;
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment