httpserver - Can nginx handle duplicated HTTP headers? -


client sending requests duplicated headers server. this:

get /somefile.txt http/1.1 host: example.com accept: */* if-modified-since: tue, 31 mar 2016 20:00:12 gmt if-modified-since: tue, 31 mar 2016 20:00:12 gmt if-modified-since: tue, 31 mar 2016 20:00:12 gmt 

apache handling requests concatenating duplicating headers ", ". resulting (handled) request like:

get /somefile.txt http/1.1 host: example.com accept: */* if-modified-since: tue, 31 mar 2016 20:00:12 gmt, tue, 31 mar 2016 20:00:12 gmt, tue, 31 mar 2016 20:00:12 gmt 

but nginx returning code 400 (bad request). can not modify client's behaviour. need tmp solution on nginx server handle these request (as apache example)

thanks.

the uniqueness check header "if-unmodified-since" hardcoded (see [1] [2]). cannot disabled or dismissed, because nginx validates headers during parsing, on stage of request processing before other handler or configuration option can intercept process. so, right answer no, unfortunately there no proper way make nginx ignore issue.

however, there 1 dirty workaround. exploits fact nginx parses request headers once , not re-validate them after internal redirect. means can intercept 400 error using error_page , internally redirect request same location:

# = important here! error_page 400 = @workaround;  location @workaround {     rewrite ^(.*)$ $1 break; } 

but beware, not how nginx meant work , there several serious drawbacks workaround:

1) first value of "if-unmodified-since" passed backend.

2) since nginx stops parsing request headers after meets error, no headers come after "if-unmodified-since" passed backend @ all.

the second drawback can quite critical, not recommend use method.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -