Handling duplicated headers

1,341 views
Skip to first unread message

luis....@interactive3g.com

unread,
Jun 16, 2016, 8:59:41 AM6/16/16
to openresty-en
Hi,

I am facing an issue where I am getting http requests with a duplicated HTTP Content-length header. NGINX is returning an error 400 Bad Request and it seems that this is hardcoded in the nginx source code [1]

Is there any way to sanitize these headers in Lua before nginx begin to parse them ? I have done some tests with header_filter_by_lua, but it seems this is executed after NGINX headers parsing.

Thanks,
Luis

Robert Paprocki

unread,
Jun 16, 2016, 10:02:32 AM6/16/16
to openre...@googlegroups.com
Header filter lua handling is for responses, not requests. If your client is sending a request with duplicate content length headers (something that very much violates spec), Nginx doesn't (and shouldn't) be able to handle this, and it's a bad request. Beyond this, request header processing is done after this, and won't be any help. Better fix your client instead. 
--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luis Gasca

unread,
Jun 16, 2016, 10:09:31 AM6/16/16
to openre...@googlegroups.com
I have no control over those invalid requests and it seems that Apache handles this with mod_headers (RequestHeader edit directive).
Just hoping that Openresty would have the equivalent to this.

Robert Paprocki

unread,
Jun 16, 2016, 11:01:22 AM6/16/16
to openre...@googlegroups.com
Ngx lua can indeed manipulate request headers, but if Nginx sees the request as bad, you're out of luck. 
Reply all
Reply to author
Forward
0 new messages