1

I've just setup nginx uploading with nginx_upload_module with the following configuration:

location = /upload {

    # backend upload_endpoint
    upload_pass @upload_endpoint;

    upload_store /var/uploads 1;

    # Set specified fields in request body
    upload_set_form_field           file[name]          "$upload_file_name";
    upload_set_form_field           file[content_type]  "$upload_content_type";
    upload_set_form_field           file[path]          "$upload_tmp_path";

    # Inform backend about hash and size of a file
    upload_aggregate_form_field     file[md5]           "$upload_file_md5";
    upload_aggregate_form_field     file[size]          "$upload_file_size";

    # remove the uploaded files if backend returns one of these HTTP status codes
    upload_cleanup 400-599;
}

# Backend file handling after uploading
location @upload_endpoint {
    internal;

    proxy_set_header    X-Real-IP                           $remote_addr;
    proxy_set_header    X-Forwarded-For                     $proxy_add_x_forwarded_for;
    proxy_set_header    X-Forwarded-Proto                   $scheme;
    proxy_set_header    Host                                $http_host;
    proxy_http_version  1.1;
    proxy_redirect      off;
    proxy_pass          http://upstream;
}

So all my uploaded files looks like the /var/uploads/00000x (x is a digit). I need to convert all incoming images to jpg format. Is it possible to make via building nginx functionality?

Erik
  • 203
  • 2
  • 5
  • 14
  • Do you need to actually convert image formats to JPEG or just append .jpg extension? – sendmoreinfo Jul 01 '15 at 21:50
  • I need to convert all images to JPEG – Erik Jul 02 '15 at 10:18
  • nginx is a web server, not an image processor. – Michael Hampton Feb 04 '19 at 17:02
  • @MichaelHampton nginx includes `ngx_http_image_filter_module` where it is possible to resize, sharpen, etc images. However, there doesn't appear to be a directive to change the file format. http://nginx.org/en/docs/http/ngx_http_image_filter_module.html – Bert Feb 04 '19 at 18:44
  • @Bert Oh yeah, I forgot about that module. But it doesn't look like it ever supported anything but the most basic operations. It seems that it still doesn't. – Michael Hampton Feb 04 '19 at 20:21

0 Answers0