| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- set $rule_root $document_root;
- location ~* /files/(.*)/(.*)\/([0-9a-z]+)\.(jpg|png|jpeg|gif)@(\d+)x(\d+)Q_([rc])$ {
- if (-f $request_filename) {
- break;
- }
- set $filepath "files/$1/$2";
- set $filename "$3.$4";
- set $thumb "$3_$5x$6.$4";
- set $width $5;
- set $height $6;
- set $type $7;
- if ( $type = 'r' ){
- set $type 'image-resize'; #旋转
- }
- if ( $type = 'c' ){
- set $type 'image-crop'; #剪切
- }
- if (!-f $document_root/$filepath/$filename) {
- return 404;
- }
- rewrite /files/(.*)/(.*)\/([0-9a-z]+)\.(.*) /imgcache/$1/$2/$thumb;
- if (!-f $request_filename) {
- proxy_pass $scheme://127.0.0.1:$server_port/$type/$filepath/$filename?width=$width&height=$height;
- break;
- }
- #proxy_store $document_root/imgcache/$1/$2/$thumb;
- #proxy_store_access user:rw group:rw all:r;
- proxy_set_header Host $host;
- expires 10d; # 设置图片过期时间10天
- }
- location ~* /attachment/(.*)/(.*)\/([0-9a-z]+)\.(jpg|png|jpeg|gif)@(\d+)x(\d+)Q_([rc])$ {
- if (-f $request_filename) {
- break;
- }
- set $filepath "attachment/$1/$2";
- set $filename "$3.$4";
- set $thumb "$3_$5x$6.$4";
- set $width $5;
- set $height $6;
- set $type $7;
- if ( $type = 'r' ){
- set $type 'image-resize'; #旋转
- }
- if ( $type = 'c' ){
- set $type 'image-crop'; #剪切
- }
- if (!-f $document_root/$filepath/$filename) {
- return 404;
- }
- rewrite /attachment/(.*)/(.*)\/([0-9a-z]+)\.(.*) /imgcache/$1/$2/$thumb;
- if (!-f $request_filename) {
- proxy_pass $scheme://127.0.0.1:$server_port/$type/$filepath/$filename?width=$width&height=$height;
- break;
- }
- #proxy_store $document_root/imgcache/$1/$2/$thumb;
- #proxy_store_access user:rw group:rw all:r;
- proxy_set_header Host $host;
- expires 10d; # 设置图片过期时间10天
- }
- location ^~ /image-resize {
- #rewrite /(image-resize)/(.*) /$2 break;
- alias $rule_root/;
- image_filter resize $arg_width $arg_height;
- image_filter_jpeg_quality 75;
- image_filter_buffer 20m;
- #allow 127.0.0.0/8;
- #deny all;
- }
- location ^~ /image-crop {
- #rewrite /(image-crop)/(.*) /$2 break;
- alias $rule_root/;
- image_filter crop $arg_width $arg_height;
- image_filter_jpeg_quality 75;
- image_filter_buffer 20m;
- #allow 127.0.0.0/8;
- #deny all;
- }
|