0

I'm using nginx(1.8.1) as a server. I make a OPTIONS request with chunked encoding body by using fiddler, and this request will go through a proxy before it gets to nginx. But the proxy have some problem with the OPTIONS request that the proxy only send the header of this request to nginx, the chunked body is NOT sent. The result is that nginx doesn't wait for the chunked body and send out a response immediately. How do I config nginx to hold the OPTIONS request header and wait for the body and then send a response to client?Thanks for your help!

Notice: because nginx can not handle OPTIONS request by default, so I add some directives in location context as below, which I learn from Handling OPTIONS request in nginx

if ($request_method = OPTIONS ) {
            #add_header Content-Length 0;
            add_header Content-Type text/plain;
            return 200;
        }

also, this is my OPTIONS request with chunked encoding body:

OPTIONS / HTTP/1.1
Transfer-Encoding: chunked
Host: myserver.com
\r\n
\r\n
2\r\n
hi\r\n
0\r\n\r\n
Community
  • 1
  • 1
ethandu7
  • 43
  • 7
  • If the proxy is not sending the body and is removing the `Transfer-Encoding` header you cannot do anything on the Nginx side, it's too late, fix the proxy. If you have the `Transfer-Encoding: chunked` header going through the proxy but without the body, this proxy is having a big security issue. – regilero Feb 09 '16 at 16:52
  • @regilero, the proxy do send the Transfer-Encoding header, it just doesn't send the body. And I am wondering what security issue would be if proxy doesn't send body. Thank you for your explanation. – ethandu7 Feb 09 '16 at 18:01
  • Well now you could have nginx effectively waiting for untransmitted chunks. You have a *partial transmission* of a message, which could become a problem if the proxy consider the message was fully transmitted and reuse the connection with another message. But the fact Nginx sends the response immediately without waiting for the body means Nginx doesn't care about the body of OPTIONS, so it's not even considered a partial message by Nginx in your case (maybe because of your special configuration). Seems this is just too advanced HTTP for this proxy and this Nginx conf. – regilero Feb 09 '16 at 18:59
  • FWIW, the `OPTIONS` request shown above is malformed; you must only have one bare `\r\n` after the headers, not two. Furthermore, it's illegal to combine `Transfer-Encoding: chunked` and a `Content-Length` header in the same request. – EricLaw Feb 09 '16 at 19:16

0 Answers0