How to install the image_filter module on NGINX Open Source?

1.3k views Asked by At

I am trying to let nginx handle my static files in my web server. To do that, I want to resize images. I found ngx_http_image_filter_module which seems to be what I want. But I can't get it to work.

Ideally, I want a solution for a docker ecosystem. In the official nginx image, I think the library is packaged in /etc/nginx/modules/ngx_http_image_filter_module.so and I heard about the load_module line with:

load_module "modules/ngx_http_image_filter_module.so";

But it does not work with me. I think it is only for nginx Plus users, and I am only using nginx open source, right ?

So, it appears I have to build nginx manually with some arguments, but I can't find a tutorial on how to do that clearly. I tried to tinker with this Dockerfile but I can't get anything to work.

I already spend a day of work on that issue and it is really frustrating, especially since there seems to be almost no documentation for something I would expect to be a very useful thing. Maybe it is simply not doable with the free nginx ? I am completely lost...

1

There are 1 answers

0
R. Hidra On

Since no one answered, I am sending my work around.

I am using nginx above a NodeJS + express web server. In my solution, the file name is formatted depending on the resizing required, like abc-123-def_w100_h200.jpg. If the file is available in the disk, nginx is serving it simply. If it doesn't exist, the request is passed to the node server. There, I test if the original image exists, I modify it using Jimp and I save it on the disk. Then express serves the modified image.

Since the image is not deleted, all the other requests for the modified image with the same parameters will pass through nginx and be much faster. Though, I don't really know how to implement a system similar to caching which would allow me to not saturate the disk of my server...