Nginx + image_filter_module + fastdfs實現上傳圖片的實時縮略圖預覽

  1. 到nginx源碼目錄配置加載模塊
    ./configure --add-module=/home/fastdfs-nginx-module-master/src/ --prefix=/usr/local/nginx --user=nobody --group=nobody --with-http_gzip_static_module --with-http_gunzip_module --with-http_image_filter_module

     

  2. make編譯,覆蓋nginx目錄文件
  3. 修改nginx配置文件
    location ~ /group1/M00/(.*)\.((?i)jpg|jpeg|gif|png)_([0-9]+)x([0-9]+) {
                    ngx_fastdfs_module;
                    rewrite group1/M00(.+)\.((?i)jpg|jpeg|gif|png)_(\d+)x(\d+)$ group1/M00$1.$2 break;
                    image_filter crop $3 $4;
                    image_filter_jpeg_quality 50;
                    image_filter_buffer 2M;
            } 
        
            location ~ /group1/M00/(.+)\.?(.+) {
                    root /home/fastdfs/storage/data;
                    ngx_fastdfs_module;
            }

     

  4. 重啓nginx
相關文章
相關標籤/搜索