server {
listen 80;
server_name shdyj.io;
root /Users/Simon/tengine/html/shdyj-data/;
access_log /Users/Simon/tengine/html/shdyj-data/nginx.log combined;
index index.html index.htm;
#charset koi8-r;
#access_log logs/host.access.log main;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ ^\/image\/([0-9]+)\/([a-zA-Z]+_\!\![0-9]+x[0-9]+)\.(gif|jpg|jpeg|png|bmp)_([rc])([0-9]+)x([0-9]+)\.(gif|jpg|jpeg|png|bmp)$ {
root /Users/Simon/tengine/html/shdyj-data/cache/;
set $width $5;
set $height $6;
if ( $width = "0" ){
set $width "-";
}
if ( $height = "0" ){
set $height "-";
}
set $type $4;
if ( $type = "r" ){
set $type "resize";
}
if ( $type = "c" ){
set $type "crop";
}
set $image_filename 'image/$1/$2.$3';
#log_format debug_log '$request_filename --> $image_filename || $width || $height';
#access_log logs/image_exsit.log combined;
proxy_set_header Host $host;
proxy_store on;
proxy_store_access user:rw group:rw all:r;
#proxy_temp_path .;
expires 30d;
if ( !-f $request_filename) {
proxy_pass http://127.0.0.1/image_$type/$image_filename?type=$type&width=$width&height=$height;
}
}
location /image_resize {
alias /Users/Simon/tengine/html/shdyj-data/;
image_filter_jpeg_quality 85;
image_filter resize $arg_width $arg_height;
#access_log /Users/Simon/tengine/html/shdyj-data/logs/image_resize.log combined;
}
location /image_crop {
alias /Users/Simon/tengine/html/shdyj-data/;
image_filter crop $arg_width $arg_height;
image_filter_jpeg_quality 85;
#access_log /Users/Simon/tengine/html/shdyj-data/logs/image_crop.log combined;
}
location ~ ^\/image\/([0-9]+)\/([a-zA-Z]+_\!\![0-9]+x[0-9]+)\.(gif|jpg|jpeg|png|bmp)$ {
expires 30d;
}
}