swindon-rs / swindon

An HTTP edge (frontend) server with smart websockets support
Apache License 2.0
101 stars 9 forks source link

Careful mode for proxying #48

Open tailhook opened 7 years ago

tailhook commented 7 years ago

There are some servers that don't obey non-body receiving responses, including:

  1. Sending 0-length chunk on 304 Not Modified
  2. Sending full response body in HEAD requests
  3. Sometimes nginx forwards zero-length chunk but strips transfer-encoding at all (see #47)

(maybe other, but at least 204 codes should be immune to the attack).

While (1) only creates errors for some clients, (2) can really be source of cache-poisoning attacks. So we might want more careful mode for keep-alive/pipelineing:

  1. Do not pipeline HEAD requests
  2. No not pipeline If-Modifed-Since and If-None-Match requests, 304 response codes.

The alternative is to disable keep-alive by default as nginx does. Another thing is we need some test suite to determine whether service behind swindon does proxying correctly. And the test suite is hard to do because the service might have some complex routing (i.e. serving static files under certain urls, serving streaming updates under certain urls), or be non-validating proxy itself (i.e. depend on the services behind for correctness).

Inspired by #47.