Using nginx upload module and nginx lua together

myxingkong myeclipse2202 at
Wed Feb 5 09:36:36 UTC 2020

I am using nginx upload module for uplaoding files to server. But I wanted nginx to upload to different paths, not to a path mentioned in upload_store. So I am taking help of nginx-lua module to change the upload_store value on each request like below.

location /umtest {
            upload_pass /nginx_response;
            set $upload_store '';
            rewrite_by_lua '
                local header = ngx.req.raw_header()
                ngx.say("type header",header)
                dst_path_dir = ngx.req.get_headers()["Dst-Dir"]
                ngx.var.upload_store = dst_path_dir
                ngx.say("upload store path" ,ngx.var.upload_store)    
                upload_set_form_field $ 
                upload_set_form_field $upload_field_name.content_type 
                upload_set_form_field $upload_field_name.path 
                upload_cleanup 400 404 499 500-505;

Now when I POST to the '/umtest' it will change the upload_store value, but it will not execute the nginx upload direcives (i.e., upload will not happen). When I comment the rewrite_by_lua directive , the upload happens. My question is cant we use both at a same time to achieve the purpose?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list