nginx-upload-progress-module icon indicating copy to clipboard operation
nginx-upload-progress-module copied to clipboard

Progress doesn't work if X-Progress-ID is set with more headers module

Open lexer opened this issue 14 years ago • 8 comments

In our application we need X-Progress-ID to be parsed from $request_url location /upload {

if ($request_uri ~* ^/upload/(.*)$) { set $progress_id $1; more_set_headers "X-Progress-ID:$progress_id"; }

proxy_pass http://127.0.0.1; proxy_redirect default;

track_uploads proxied 30s; }

However progress doesn't work in this case.

lexer avatar Mar 10 '11 13:03 lexer

Can you attach (or send me privately by e-mail) the full debug log (you'll need to compile nginx with --with-debug)? I think "more_set_headers" phase happens after the upload is registered in the upload progress module, which I'm afraid can't be fixed easily, but I'd like to check first with the log.

masterzen avatar Mar 10 '11 13:03 masterzen

I've mailed it to you.

lexer avatar Mar 10 '11 15:03 lexer

I also checked debug log and as you suggest get_tracking_id is called earlier then headers are set.

How can I fix it?

lexer avatar Mar 10 '11 17:03 lexer

I also checked debug log and as you suggest get_tracking_id is called earlier then headers are set.

How can I fix it?

lexer avatar Mar 10 '11 17:03 lexer

Hmm, reading more headers documentation, it looks like "more_set_headers" sets output headers (the one that will be returned to the client). Can you try with "more_set_input_header" instead?

masterzen avatar Mar 10 '11 18:03 masterzen

Yep, that solve half of problem. But first call get_tracking_id is performed earlier then setting of headers.

In our application we need to proxy traffic to Amazon that reject requests with querystring.

So currently we have solve problem in following way. We receive querystring param. Set header using querystring value and then remove querystring with rewriting.

location /upload {      

    if ($request_uri ~* "^/upload\?X-Progress-ID=(.*)$") {
        set $progress_id $1;
        more_set_input_headers "X-Progress-ID: $progress_id";       
    }

    set $args "";
    rewrite ^(.*)$ / break; 

    proxy_pass http://myamazonbucket.s3.amazonaws.com/;             
    #proxy_redirect default;        
    track_uploads proxied 30s;
}

lexer avatar Mar 11 '11 06:03 lexer

Do you mean the problem is solved by the rewrite break?

masterzen avatar Mar 11 '11 10:03 masterzen

Rewrite required to remove "/upload". set $args "" removes "X-Progress-ID" from querystring.

lexer avatar Mar 11 '11 10:03 lexer