configuration - Nginx server config optimisation using image_filter and proxy_cache -
i have nginx server config file below setup , working fine, wondered if there way of optimising there isn't repetition proxy settings.
i want restrict resizing can done specific pre-set dimensions, rather allowing /resized/200x100/image.jpg
example.
i'm serving these images via ghost, can prepend or append url.
upstream backend { server domain.name; } proxy_cache_path /var/www/cache/resized levels=1:2 keys_zone=resizedimages:10m max_size=1g; server { listen 80; root /var/www/domain/source; server_name domain.name; image_filter_buffer 10m; image_filter_jpeg_quality 85; proxy_store_access user:rw group:rw all:rw; location / { proxy_pass http://127.0.0.1:2368; proxy_redirect off; } location ~ /resize/xs/(.*) { proxy_pass http://backend/$1; proxy_cache resizedimages; proxy_cache_valid 200 1d; proxy_cache_valid 1m; proxy_cache_use_stale error timeout invalid_header updating; image_filter resize 320 -; } location ~ /resize/xs@2x/(.*) { proxy_pass http://backend/$1; proxy_cache resizedimages; proxy_cache_valid 200 1d; proxy_cache_valid 1m; proxy_cache_use_stale error timeout invalid_header updating; image_filter resize 480 -; image_filter_jpeg_quality 65; } location ~ /resize/sm/(.*) { proxy_pass http://backend/$1; proxy_cache resizedimages; proxy_cache_valid 200 1d; proxy_cache_valid 1m; proxy_cache_use_stale error timeout invalid_header updating; image_filter resize 480 -; } location ~ /resize/sm@2x/(.*) { proxy_pass http://backend/$1; proxy_cache resizedimages; proxy_cache_valid 200 1d; proxy_cache_valid 1m; proxy_cache_use_stale error timeout invalid_header updating; image_filter resize 720 -; image_filter_jpeg_quality 65; } # md, m@2x, etc. location ~ /resized/(sq/xs|sq/md|xs|xs@2x|sm|sm@2x|md|md@2x|lg|lg@2x|xl|xl@2x)/(.*) { try_files /resize$1/$2 @img; } location @img { proxy_pass http://backend/resize/$1/$2; proxy_store /var/www/domain/cache/$1/$2; } }
Comments
Post a Comment