Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPTIONS request with no body results in 503 errors when Varnish is enabled #28

Closed
GUI opened this issue Jun 3, 2014 · 2 comments
Closed

Comments

@GUI
Copy link
Member

GUI commented Jun 3, 2014

When api-umbrella-gatekeeper is routing the Varnish for caching (the default), an OPTIONS request without a body will result in a 503 server error being returned from Varnish. If Varnish is bypassed, then most servers seem fine with the request.

The culprit seems to be a combination of node-http-proxy and Varnish. node-http-proxy seems to add a Transfer-Encoding: chunked header onto the request as it passes through. But without a body to the request, Varnish doesn't like this. Varnish 3 dies with a 503 error, while Varnish 4 dies while slightly more telling 411 error ("length required - no chunk, no close, no size"). But if the HTTP body is set to anything (even an empty string), then Varnish has no problem with these chunked requests.

So on the one hand, Varnish seems to be pickier about this situation than other servers (nginx and haproxy don't seem to care if chunked requests are sent without an actual body), but on the other hand, node-http-proxy's behavior of adding the Transfer-Encoding: chunked header doesn't actually seem valid when there is no body.

The issue appears similar to this older issue with node-http-proxy and DELETE requests with no body: http-party/node-http-proxy#373 Similar to that fix, I think the most straight-forward fix could be to delete this Transfer-Encoding header if there is no body for OPTIONS requests: https://github.com/nodejitsu/node-http-proxy/blob/v0.10.4/lib/node-http-proxy/http-proxy.js#L284-L287

@GUI
Copy link
Member Author

GUI commented Jun 3, 2014

The underlying issue of the Transfer-Encoding: chunked header being added actually looks like it might stem from nodejs (so it's not specific to node-http-proxy): nodejs/node-v0.x-archive#6185

We can still workaround this in our stack, by stripping that header for OPTIONS requests (similar to how node-http-proxy was working around this issue for DELETE requests). However, we should also investigate a bit more and see about getting this patched in nodejs itself.

@GUI
Copy link
Member Author

GUI commented Jul 10, 2014

This was fixed a while ago by: NREL/api-umbrella-gatekeeper@e8745f2

In addition, the underlying bug has been fixed in nodejs (but it won't land until node 0.12): nodejs/node-v0.x-archive#7725

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant