Page MenuHomePhabricator

Proxy-connection HTTP response header being sent to some users in some cases causing HTTP/2 protocol errors
Closed, ResolvedPublic

Description

Filing on behalf of a user without an SUL account
https://wm-bot.wmflabs.org/logs/%23wikimedia-tech/20191117.txt (beginning 23:17:00)
https://wm-bot.wmflabs.org/logs/%23wikimedia-tech/20191118.txt

key parts:

[23:17:00] <temp20191117>	 Hello, I have a question / observation about Wikipedia and HTTP/2
[23:17:41] <temp20191117>	 I went to the following article in Safari 12.1.1 on macOS and the CSS did not load: https://en.wikipedia.org/wiki/Ford_C-Max
[23:18:13] <temp20191117>	 it seems the following CSS did not load: https://en.wikipedia.org/w/load.php?lang=en&modules=ext.cite.styles%7Cext.uls.interlanguage%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikimediaBadges%7Cjquery.makeCollapsible.styles%7Cmediawiki.legacy.commonPrint%2Cshared%7Cmediawiki.page.gallery.styles%7Cmediawiki.skinning.interface%7Cmediawiki.toc.styles%7Cskins.vector.styles%7Cwikibase.client.init&only=styles&skin=
[23:18:21] <temp20191117>	 shortened: https://preview.tinyurl.com/yxx4blmr
[23:18:36] <temp20191117>	 Safari gave an error about "NSPOSIXErrorDomain:100"
[23:18:47] <temp20191117>	 this seems to be something to do with HTTP/2
[23:19:08] <temp20191117>	 trying the URL with cURL on the macOS CLI I get:
[23:19:11] <temp20191117>	 $ curl 'https://en.wikipedia.org/w/load.php?lang=en&modules=ext.cite.styles%7Cext.uls.interlanguage%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikimediaBadges%7Cjquery.makeCollapsible.styles%7Cmediawiki.legacy.commonPrint%2Cshared%7Cmediawiki.page.gallery.styles%7Cmediawiki.skinning.interface%7Cmediawiki.toc.styles%7Cskins.vector.styles%7Cwikibase.client.init&only=styles&skin=vector'
[23:19:11] <temp20191117>	 curl: (92) HTTP/2 stream 1 was not closed cleanly: PROTOCOL_ERROR (err 1)
[23:19:35] <temp20191117>	 however, forcing HTTP/1.1 works:

[23:34:40] <temp20191117> yeah; found a Stack Overflow question (w/o answers) which sound similar: https://apple.stackexchange.com/questions/374097/
[23:47:48] <temp20191117> * http2 error: Invalid HTTP header field was received: frame type: 1, stream: 1, name: [proxy-connection], value: [keep-alive]
[01:00:09] <temp20191117> can you add the weblog post to the ticket as a note? https://megamorf.gitlab.io/2019/08/27/safari-nsposixerrordomain-100-error-with-nginx-and-apache.html

I tried some of the same requests and got all the same header keys except this problematic one - even tried forcing my traffic to go to directly to eqiad in case there was some distinction.
User has said they are not behind an MITM proxy.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

@ema this could be caused by ats-be? ats-tls is setting would set Proxy-Connection: close but we are actually preventing that reaching varnish-fe cause we've seen connection reusing issues on the backend layer caused by that (See T233205 for more details)

From what I'm seeing on https://github.com/apache/trafficserver/blob/8.0.x/proxy/http/HttpTransact.cc#L6859-L6882 I don't think ATS is at fault here:

// Insert K-A headers as necessary
switch (ka_action) {
case KA_CONNECTION:
  ink_assert(s->client_info.keep_alive != HTTP_NO_KEEPALIVE);
  // This is a hack, we send the keep-alive header for both 1.0
  // and 1.1, to be "compatible" with Akamai.
  // if (ver == HTTPVersion (1, 0)) {
  heads->value_set(c_hdr_field_str, c_hdr_field_len, "keep-alive", 10);
  // NOTE: if the version is 1.1 we don't need to do
  //  anything since keep-alive is assumed
  break;
case KA_CLOSE:
case KA_DISABLED:
  if (s->client_info.keep_alive != HTTP_NO_KEEPALIVE || (ver == HTTPVersion(1, 1))) {
    heads->value_set(c_hdr_field_str, c_hdr_field_len, "close", 5);
    s->client_info.keep_alive = HTTP_NO_KEEPALIVE;
  }
  // Note: if we are 1.1, we always need to send the close
  //  header since persistant connnections are the default
  break;
default:
  ink_assert(0);
  break;
}

[proxy-]connection: keep-alive is only added for http/1.0 connections, so that shouldn't happen for HTTP/2 requests at all

as a PoC, you can force ATS to send proxy-connection: keep-alive using HTTP/1.0 like this:

$ curl --http1.0 -H 'Proxy-Connection: keep-alive' 'https://en.wikipedia.org/w/load.php?lang=en&modules=ext.cite.styles%7Cext.uls.interlanguage%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikimediaBadges%7Cjquery.makeCollapsible.styles%7Cmediawiki.legacy.commonPrint%2Cshared%7Cmediawiki.page.gallery.styles%7Cmediawiki.skinning.interface%7Cmediawiki.toc.styles%7Cskins.vector.styles%7Cwikibase.client.init&only=styles&skin=vector' -v -o /dev/null 2>&1 |grep Connection
> Proxy-Connection: keep-alive
< Proxy-Connection: keep-alive

As soon as I switch to HTTP/2, you can see how curl sends the header but ATS doesn't add it to the response nor the request fails:

$ curl --http2 -H 'Proxy-Connection: keep-alive' 'https://en.wikipedia.org/w/load.php?lang=en&modules=ext.cite.styles%7Cext.uls.interlanguage%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikimediaBadges%7Cjquery.makeCollapsible.styles%7Cmediawiki.legacy.commonPrint%2Cshared%7Cmediawiki.page.gallery.styles%7Cmediawiki.skinning.interface%7Cmediawiki.toc.styles%7Cskins.vector.styles%7Cwikibase.client.init&only=styles&skin=vector' -v -o /dev/null 2>&1 |grep Connection
* Connection state changed (HTTP/2 confirmed)
> Proxy-Connection: keep-alive
* Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
* Connection #0 to host en.wikipedia.org left intact

so we have been able to reproduce the issue, apparently this happens when nginx is being used as the TLS termination layer and the request is being handled by an ats-be instance, in those cases Proxy-Connection: keep-alive is added by ats-be and it isn't stripped by nginx. This will be solved tomorrow as soon as I get of the last nginx instances

Marking this as resolved as we don't use nginx anymore to terminate TLS in the caching cluster now that T231627 has been completed.