Skip to content

Instantly share code, notes, and snippets.

@phpdude
Last active October 6, 2024 19:22
Show Gist options
  • Select an option

  • Save phpdude/1451684 to your computer and use it in GitHub Desktop.

Select an option

Save phpdude/1451684 to your computer and use it in GitHub Desktop.

Revisions

  1. phpdude revised this gist Feb 18, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    set $width $1;
    set $height $2;
    set $image_path $3;
    set $demins "_$1x$2";
    set $dimens "_$1x$2";
    }
    if ($uri ~* "^/resize/(.*)" ) {
    set $image_path $1;
    @@ -20,7 +20,7 @@
    break;
    }

    proxy_store /tmp/nginx/resize$demins/$image_path;
    proxy_store /tmp/nginx/resize$dimens/$image_path;
    proxy_store_access user:rw group:rw all:r;
    proxy_temp_path /tmp/images;
    proxy_set_header Host $host;
  2. Alexandr Shurigin revised this gist Dec 9, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nginx.conf
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@
    set $demins "_$1x$2";
    }
    if ($uri ~* "^/resize/(.*)" ) {
    set $image_path $3;
    set $image_path $1;
    }
    set $image_uri image_resize/$image_path?width=$width&height=$height;

  3. Alexandr Shurigin created this gist Dec 9, 2011.
    35 changes: 35 additions & 0 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    location /resize {
    alias /tmp/nginx/resize;
    set $width 150;
    set $height 100;
    set $dimens "";

    if ($uri ~* "^/resize_(\d+)x(\d+)/(.*)" ) {
    set $width $1;
    set $height $2;
    set $image_path $3;
    set $demins "_$1x$2";
    }
    if ($uri ~* "^/resize/(.*)" ) {
    set $image_path $3;
    }
    set $image_uri image_resize/$image_path?width=$width&height=$height;

    if (!-f $request_filename) {
    proxy_pass http://127.0.0.1:8080/$image_uri;
    break;
    }

    proxy_store /tmp/nginx/resize$demins/$image_path;
    proxy_store_access user:rw group:rw all:r;
    proxy_temp_path /tmp/images;
    proxy_set_header Host $host;
    }

    location /image_resize {
    alias /path/to/media/;
    image_filter resize $arg_width $arg_height;
    image_filter_jpeg_quality 75;
    allow 127.0.0.0/8;
    deny all;
    }
    5 changes: 5 additions & 0 deletions readme.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    Nginx image filter + caching of results.

    Supports dynamic thumbnails images sizes processing + caching results, simple to use.

    Awesome!!!