Nginx的 http_image_filter_module

邢华清
2023-12-01

1、安装依赖 

yum -y install gd-devel

2、下载nginx

现在新版本的nginx,注意老版本可能不支持

wget http://nginx.org/download/nginx-1.20.1.tar.gz

3、解压安装

tar -zxvf nginx-1.20.1.tar.gz

 4、编译安装

cd nginx-1.20.1

./configure --prefix=/opt/software/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_image_filter_module=dynamic

make

5、查看版本

./objs/nginx -V

6、备份历史nginx

mv /opt/software/nginx/sbin/nginx /opt/software/nginx/sbin/nginx-bak

7、使用新nginx 

mv objs/nginx /opt/software/nginx/sbin/

8、 

mkdir /opt/software/nginx/modules

mv objs/ngx_http_image_filter_module.so /opt/software/nginx/modules

cd /opt/software/nginx/

nginx -s quit

sbin/nginx

修改配置

vim conf/nginx.conf

load_module /opt/software/nginx/modules/ngx_http_image_filter_module.so;

       location ~* /resource/(.*)_(\d+)x(\d+)$ {

        set $img_width $2;

        set $img_height $3;

        image_filter resize $img_width $img_height;

        image_filter_buffer 10M;

        rewrite ^/resource/(.*?)_(\d+)x(\d+)$ /$1 break;

        proxy_pass http://127.0.0.1:8888;

      }

        location /resource/ {

           proxy_set_header Host $host:$server_port;

           proxy_pass http://127.0.0.1:8888/;

        }

 

 类似资料: