IP Cam returns 400: bad request when accessed through reverse proxy

I couldn’t see anything in the nginx logs which looked relevant, the cam has a very basic log that only shows logins and nothing more.

My approach to finding a fix was to build a little application in javascript to send custom requests to the ip cam. First, I added alle the fields from the direct request and then started adding the fields from the request sent by nginx. After I added the cookie field (which holds a lot of data), I got the bad request message from the cam.

My solution then was to add

proxy_set_header Cookie "";

to the config and it finally worked.

I still don’t know why nginx adds the cookie field or why the cam didn’t like it, but I am happy that I got it working.

The only thing that catched my attention was that the http request had to be split up into two tcp packets because of the rather big cookie field exceeding the maximum packet size. So it could be that the tcp stack in the cam is not able to handle fragmented packets. But this is just a guess, my knowledge in this area is very limited.