diff --git a/vhost/demo.conf b/vhost/demo.conf index 0da8627..bb35996 100644 --- a/vhost/demo.conf +++ b/vhost/demo.conf @@ -6,15 +6,26 @@ server { root $root_path; - location / { - index index.html index.htm; - } - location /lua { default_type 'text/plain'; content_by_lua 'ngx.say("hello, ttlsa lua")'; } + location / { + try_files $uri $uri/ /index.php?$args; + + # add support for img which has query params, + # like: xxx.jpg?a=b&c=d_750x750.jpg + if ($args ~* "^([^_]+)_(\d+)+x(\d+)+\.(jpg|jpeg|gif|png)$") { + set $w $2; + set $h $3; + set $img_ext $4; + + # rewrite ^\?(.*)$ _${w}x${h}.$img_ext? last; + rewrite ([^.]*).(jpg|jpeg|png|gif)$ $1.$2_${w}x${h}.$img_ext? permanent; + } + } + # set var for thumb pic set $upload_path /opt/uploads; set $img_original_root $upload_path;# original root; diff --git a/vhost/fdfs.conf b/vhost/fdfs.conf index d3c7356..1cd8e0a 100644 --- a/vhost/fdfs.conf +++ b/vhost/fdfs.conf @@ -37,25 +37,21 @@ server{ } location /pic/M00 { + # add support for img which has query params, + # like: xxx.jpg?a=b&c=d_750x750.jpg + if ($args ~* "^([^_]+)_(\d+)+x(\d+)+\.(jpg|jpeg|gif|png)$"){ + set $w $2; + set $h $3; + set $img_ext $4; + + # rewrite ^\?(.*)$ _${w}x${h}.$img_ext? last; + rewrite ([^.]*).(jpg|jpeg|png|gif)$ $1.$2_${w}x${h}.$img_ext? permanent; + } + alias /opt/fastdfs/pic/store0/data; ngx_fastdfs_module; } - location /chat/M00 { - alias /opt/fastdfs/chat/store0/data; - ngx_fastdfs_module; - } - - location /avatar/M00 { - alias /opt/fastdfs/avatar/store0/data; - ngx_fastdfs_module; - } - - location /media/M00 { - alias /opt/fastdfs/media/store0/data; - ngx_fastdfs_module; - } - location = /favicon.ico { log_not_found off; access_log off;