PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, May 14, 2022

[FIXED] how to resize images via nginx

 May 14, 2022     nginx, ubuntu     No comments   

Issue

everybody. tell me how to solve this puzzle. Nginx passes the URL type https://example.com/thumbs/_default_upload_bucket/236/280/5804.jpeg If this image does not exist, nginx should retrieve and resize the original image: replace "thumbs/" and size "236/280/" URL will be https://example.com/_default_upload_bucket/5804.jpeg

If I understand correctly to do this through the module ngx_http_image_filter_module.

How to do this through nginx. Thanks.


Solution

after research, i created a configuration that needed to me.

location ~* /thumbs/(.*)/(\d+)/(\d+)/(.*)$ {
            set $bucket $1;
            set $width $2;
            set $height $3;
            set $filename $4;
    try_files /$1/$2/$3/$4 @images;
    root /var/www/html/tmp/image-thumbnails;
    expires 2w;
    access_log off;
}


location @images {
            root /var/www/html/assets/;
            rewrite ^.*$ /$bucket/$filename break;
            image_filter_buffer 50M;
            image_filter resize $width $height;
}


Answered By - James M
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing