From e2e9142d1ada7ed9cfbd2d882e544f966798634f Mon Sep 17 00:00:00 2001 From: Tudor Pop Date: Sat, 21 Nov 2026 02:01:00 +0200 Subject: [PATCH] envoy: under client_address connection the auth check is told the connection's scheme, HAProxy's less strict list is checked against nginx's, and the conformance page keeps no count a check does not read (Part of #70, #71, #72) With auth.send_request and client_address connection, the Envoy output told the auth check the request's own scheme, which a client writes: an HTTP/2 request sent over plain HTTP with :scheme https made the check read https (measured on Envoy 1.40.2), and an http target sent over TLS made it read http. The check is now told the listener's scheme, https with tls and http without. Under forwarded nothing changes, and a file without those two keys renders byte for byte as before. HAProxy, measured on a plain connection file for the first time, already told the connection's scheme, and so does nginx since #65; neither generator's output changes. The battery holds the scheme each proxy tells the check for a request line, an HTTP/2 :scheme and a client's own header, on a plain and a TLS file under connection, on every entry. Of the three differences measured on nginx for #65, one holds on HAProxy, the admin listener answering an absolute target, and its list has 12 entries; the page says what was measured for the other two. The notes of client_address name the X-Forwarded-For of a client on a loopback address, where the Envoy output appends its own address and the nginx and HAProxy outputs 127.0.0.1. docs/conformance.md gives each scenario's rows in digits, and the battery checks them, and the rows sent as their scenario starts, before any container starts; every other count of the present is gone from the page. The pages' copies of the support table's notes and of render's line are generated. --- conformance/client_test.go | 4 + conformance/counts_test.go | 167 +++++++++++++- conformance/raw_test.go | 15 +- conformance/scenario_test.go | 3 + conformance/scenarios_test.go | 121 +++++++---- conformance/targets_haproxy_test.go | 6 +- conformance/targets_test.go | 8 +- conformance/testdata/connection.yaml | 27 +++ conformance/testdata/nginx-connection.yaml | 26 --- docs/auth.md | 27 ++- docs/commands.md | 4 +- docs/conformance.md | 203 ++++++++++-------- docs/defaults.md | 3 +- docs/format.md | 10 + docs/haproxy.md | 31 ++- docs/listener.md | 7 +- docs/nginx.md | 12 +- docs/portability.md | 6 +- examples/full/hocon/envoy.yaml | 2 +- examples/full/yaml/envoy.yaml | 2 +- examples/portable/hocon/envoy.yaml | 2 +- examples/portable/yaml/envoy.yaml | 2 +- internal/cli/cli_test.go | 2 +- .../envoy/fragments/filter-ext-authz.yaml | 13 +- internal/envoy/generate.go | 32 ++- internal/format/docs_test.go | 25 ++- internal/format/support.go | 38 ++++ internal/format/support_haproxy.go | 38 ++-- internal/format/support_nginx.go | 31 +-- internal/format/support_test.go | 35 ++- internal/haproxy/haproxy.cfg.tmpl | 3 +- internal/nginx/auth.go | 12 +- internal/nginx/generate.go | 3 +- internal/nginx/generate_test.go | 5 +- internal/render/render_test.go | 21 ++ internal/render/testdata/full.expected.yaml | 2 +- 36 files changed, 680 insertions(+), 268 deletions(-) create mode 100644 conformance/testdata/connection.yaml delete mode 100644 conformance/testdata/nginx-connection.yaml diff --git a/conformance/client_test.go b/conformance/client_test.go index a8c1d0b..6d20765 100644 --- a/conformance/client_test.go +++ b/conformance/client_test.go @@ -141,6 +141,10 @@ func (w *world) send(r request) result { } return w.sendRaw(r) } + if r.plain { + // net/http's clients speak TLS to a file with tls, so plain HTTP to its port is sent by hand. + panic(fmt.Sprintf("the battery sends plain HTTP to a listener with tls as a raw request only, not %+v", r)) + } return w.sendOn(w.client(r), r) } diff --git a/conformance/counts_test.go b/conformance/counts_test.go index 5a0e346..e622f9b 100644 --- a/conformance/counts_test.go +++ b/conformance/counts_test.go @@ -64,7 +64,9 @@ func rowsOnFiles(files []fileKeys) map[string]int { // pageCountProblems returns a line for each count of rows docs/conformance.md gives that differs from what the // entries run, with the page's number and the counted one: the rows of each group of entries on each of its files, -// those of each group, and those in all. The counts used to be kept by hand, and went stale each time a row was added. +// those of each group, and those in all, the rows of each scenario on each file of Envoy's entry +// (scenarioCountProblems), and the rows sent as their scenario starts (overlapCountProblems). The counts used to be +// kept by hand, and went stale each time a row was added. // It also returns a line when the page names a file a group runs no row on, when two entries of one group run // different rows, and when an entry belongs to no group or to two, as the page gives one count for each group. func pageCountProblems(ts []target, byEntry map[string][]fileKeys) []string { @@ -72,10 +74,15 @@ func pageCountProblems(ts []target, byEntry map[string][]fileKeys) []string { if err != nil { return []string{fmt.Sprintf("reading the counts of rows: %v", err)} } + var envoy []fileKeys + if i := slices.IndexFunc(ts, func(tg target) bool { return tg.name == "envoy" }); i >= 0 { + envoy = byEntry[ts[i].label] + } + scenarioLines := slices.Concat(scenarioCountProblems(string(text), envoy), overlapCountProblems(string(text))) passage := countsPassage.FindStringSubmatch(strings.Join(strings.Fields(string(text)), " ")) if passage == nil { - return []string{fmt.Sprintf("%s holds no passage from %q to %q, which gives the rows each entry runs", pageName, - "The scenarios run in this order: ", "in all")} + return append([]string{fmt.Sprintf("%s holds no passage from %q to %q, which gives the rows each entry runs", pageName, + "The scenarios run in this order: ", "in all")}, scenarioLines...) } breakdown, totals := passage[1], passage[2] var lines []string @@ -147,7 +154,159 @@ func pageCountProblems(ts []target, byEntry map[string][]fileKeys) []string { } lines = appendDiffering(lines, m[1], total, "the rows in "+g.words) } - return appendDiffering(lines, passage[3], all, "the rows in all") + return append(appendDiffering(lines, passage[3], all, "the rows in all"), scenarioLines...) +} + +// The table of the scenarios starts with its header and runs to the first line that is no row of it. Each row names a +// scenario in its first cell and ends its last with the rows the scenario runs on each file of Envoy's entry, the one +// entry that runs every file: "In Envoy's entry: " and a count on each file, such as "150 rows on `full`, `portable` +// and `nginx-file`" or "3 on `nginx-limits`", which may say after a count why a file runs fewer rows but holds no other +// number, so a count the battery cannot read in this form fails the run rather than go unchecked. +var ( + scenarioTableHead = "| Scenario | Keys | What its rows check |\n|---|---|---|\n" + scenarioCounts = regexp.MustCompile("In Envoy's entry: (.*)\\.$") + countOnFiles = regexp.MustCompile("([0-9][0-9,]*) (?:rows? )?on (`[^`]+`(?:(?:, | and )`[^`]+`)*)") +) + +// scenarioCountProblems returns a line for each count of rows the table of the scenarios in text gives that differs +// from what the scenario runs on that file of Envoy's entry, whose rendered files are envoy, with the page's number and +// the counted one. It also returns a line for a scenario with no row in the table or with two, a row that names no +// scenario or holds other than three cells, a last cell that does not end with the rows in Envoy's entry or holds a number it does +// not read as a count, a file a count names twice or that the scenario runs no row on, and a file the scenario runs +// rows on that no count names. +func scenarioCountProblems(text string, envoy []fileKeys) []string { + start := strings.Index(text, scenarioTableHead) + if start < 0 { + return []string{fmt.Sprintf("%s holds no table of the scenarios, a header %q", pageName, strings.SplitN(scenarioTableHead, "\n", 2)[0])} + } + byName := map[string][]string{} + var lines []string + for _, row := range strings.Split(text[start+len(scenarioTableHead):], "\n") { + if !strings.HasPrefix(row, "|") { + break + } + cell := cells(row) + switch { + case len(cell) != 3: + lines = append(lines, fmt.Sprintf("the row %q of the table of the scenarios in %s holds %d cells, where it must hold three: a | inside a cell is written \\|", + cell[0], pageName, len(cell))) + case byName[cell[0]] != nil: + // A second row of a name would be read in place of the first, so a stale count in either goes unread. + lines = append(lines, fmt.Sprintf("the table of the scenarios in %s has two rows of the scenario %q", pageName, cell[0])) + default: + byName[cell[0]] = cell + } + } + for _, s := range scenarios { + cell, ok := byName[s.name] + if !ok { + lines = append(lines, fmt.Sprintf("the table of the scenarios in %s has no row of the scenario %q", pageName, s.name)) + continue + } + delete(byName, s.name) + counted := map[string]int{} + for _, f := range envoy { + for _, e := range s.exchanges { + if f.runs(s, e) { + counted[f.label]++ + } + } + } + what := fmt.Sprintf("the rows of the scenario %q", s.name) + clause := scenarioCounts.FindStringSubmatch(cell[2]) + if clause == nil || strings.Count(cell[2], "In Envoy's entry: ") != 1 { + lines = append(lines, fmt.Sprintf("%s's row of the scenario %q does not end with one sentence of its rows on each file of Envoy's entry, which starts %q", + pageName, s.name, "In Envoy's entry: ")) + continue + } + pairs := countOnFiles.FindAllStringSubmatch(clause[1], -1) + if found := len(countNumber.FindAllString(backquoted.ReplaceAllString(clause[1], ""), -1)); found != len(pairs) { + lines = append(lines, fmt.Sprintf("%s holds %d numbers in %s on each file of Envoy's entry, %q, and the battery reads %d of them as counts", + pageName, found, what, clause[1], len(pairs))) + } + given := map[string]bool{} + for _, pair := range pairs { + for _, label := range backquoted.FindAllString(pair[2], -1) { + label = strings.Trim(label, "`") + switch _, runs := counted[label]; { + case given[label]: + lines = append(lines, fmt.Sprintf("%s names `%s` twice in %s in Envoy's entry", pageName, label, what)) + case !runs: + lines = append(lines, fmt.Sprintf("%s gives %s as %s on `%s` in Envoy's entry, a file it runs no row on", pageName, pair[1], what, label)) + default: + lines = appendDiffering(lines, pair[1], counted[label], fmt.Sprintf("%s on `%s` in Envoy's entry", what, label)) + } + given[label] = true + } + } + for _, label := range slices.Sorted(maps.Keys(counted)) { + if !given[label] { + lines = append(lines, fmt.Sprintf("%s gives no count of %s on `%s` in Envoy's entry, and the battery counts %s", + pageName, what, label, commas(counted[label]))) + } + } + } + for _, name := range slices.Sorted(maps.Keys(byName)) { + lines = append(lines, fmt.Sprintf("the table of the scenarios in %s has a row %q, which names no scenario", pageName, name)) + } + return lines +} + +// The rows sent as their scenario starts (exchange.overlap) are given in one sentence of the page, read with its white +// space made single spaces: those of every scenario but tracing, which wait for a proxy's timer or its close, and +// those of the tracing scenario, each a count in digits before these words. +const ( + overlapOthers = "rows that wait for a proxy's timer or its close" + overlapTracing = "rows of the tracing scenario" +) + +// overlapCountProblems returns a line when text, the page, does not give each count of the rows sent as their scenario +// starts once, or gives another number than the scenarios hold: the rows of the tracing scenario and those of the +// others. They are rows of the scenarios, whatever file runs them. +func overlapCountProblems(text string) []string { + flat := strings.Join(strings.Fields(text), " ") + var others, traced int + for _, s := range scenarios { + for _, e := range s.exchanges { + switch { + case !e.overlap: + case s.name == tracing.name: + traced++ + default: + others++ + } + } + } + var lines []string + for _, c := range []struct { + words string + counted int + }{{overlapOthers, others}, {overlapTracing, traced}} { + found := regexp.MustCompile("([0-9][0-9,]*) "+regexp.QuoteMeta(c.words)).FindAllStringSubmatch(flat, -1) + if len(found) != 1 { + lines = append(lines, fmt.Sprintf("%s gives %d times a count in digits of the %s, where it must give it once, and the battery counts %s", + pageName, len(found), c.words, commas(c.counted))) + continue + } + lines = appendDiffering(lines, found[0][1], c.counted, "the "+c.words) + } + return lines +} + +// cells returns the cells of a row of a Markdown table, split at each | no backslash escapes, as GitHub splits it: a | +// inside a code span that is not escaped ends the cell there, and GitHub drops what comes after the third cell. +func cells(row string) []string { + var found []string + var cell strings.Builder + for i := 1; i < len(strings.TrimSuffix(row, "|")); i++ { + if row[i] == '|' && row[i-1] != '\\' { + found = append(found, strings.TrimSpace(cell.String())) + cell.Reset() + continue + } + cell.WriteByte(row[i]) + } + return append(found, strings.TrimSpace(cell.String())) } // appendDiffering appends a line to lines when page, a count as the page writes it, is not counted, the count of what, diff --git a/conformance/raw_test.go b/conformance/raw_test.go index 5f7a357..29d73df 100644 --- a/conformance/raw_test.go +++ b/conformance/raw_test.go @@ -25,8 +25,8 @@ import ( // HEADERS frame of the same fields, each a literal HPACK field with no index and no Huffman coding, then the body as a // DATA frame and the trailers as a second HEADERS frame, and reads frames until the stream ends. A closed or reset connection, or a // GOAWAY, before the answer is an error, as a client sees a proxy that refused the request so. The connection is the -// clients' own (TLS with the client certificate, or plain), opened for this request alone. With r.halfClose it closes -// its side once the request is written (closeWrite). +// clients' own (TLS with the client certificate, or plain), opened for this request alone, and plain with r.plain. With +// r.halfClose it closes its side once the request is written (closeWrite). func (w *world) sendRaw(r request) result { if r.pause != 0 && (r.proto != "http/1.1" || !r.unframed) { // A pause inside any other body is a mistake in the scenario data, which panics, as send does. @@ -38,9 +38,18 @@ func (w *world) sendRaw(r request) result { if r.then != "" && (r.proto != "http/1.1" || !r.unframed || r.pause != 0 || r.halfClose) { panic(fmt.Sprintf("the battery sends a second request after an unframed http/1.1 body with no pause or half-close only, not %+v", r)) } + if r.plain && (r.proto != "http/1.1" || w.plain) { + panic(fmt.Sprintf("the battery sends plain HTTP over http/1.1 to a listener with tls only, not %+v", r)) + } start := time.Now() fail := func(err error) result { return result{err: err, elapsed: time.Since(start)} } - conn, err := w.dialRaw(r.proto, serverNameFor(r)) + var conn net.Conn + var err error + if r.plain { + conn, err = (&net.Dialer{Timeout: 20 * time.Second}).Dial("tcp", w.listener) + } else { + conn, err = w.dialRaw(r.proto, serverNameFor(r)) + } if err != nil { return fail(err) } diff --git a/conformance/scenario_test.go b/conformance/scenario_test.go index 9ad76bf..18e4eea 100644 --- a/conformance/scenario_test.go +++ b/conformance/scenario_test.go @@ -162,6 +162,9 @@ type request struct { // scheme, on a raw h2 request, is the :scheme sent in place of the connection's own, https with tls and http // without, as a client in front may send one that differs from the connection it uses. scheme string + // plain, on a raw http/1.1 request to a file with tls, opens the connection with no TLS, as a client does that + // writes http:// for the TLS port. + plain bool // then, on a raw unframed http/1.1 request, is a second request written on the same connection right after the // body, in the same write, as a client that reuses its connection sends its next request: the answer compared is // the second's, and the first's status is answer.first. A proxy that answers the first without reading its body diff --git a/conformance/scenarios_test.go b/conformance/scenarios_test.go index 416ef89..8584a97 100644 --- a/conformance/scenarios_test.go +++ b/conformance/scenarios_test.go @@ -739,6 +739,15 @@ var mutualTLS = scenario{name: "mutual TLS", send: offered(tlsOffer{groups: []tls.CurveID{tls.CurveP384}}), want: answer{refused: true}}, {name: "a client that offers only the group X25519MLKEM768 is served", keys: serverKeys, send: offered(tlsOffer{groups: []tls.CurveID{tls.X25519MLKEM768}}), want: answer{status: 200, service: "shop"}}, + // measured on Envoy 1.40.2 and HAProxy 3.2.26 and 3.4.7: the connection is closed with no answer, and nginx + // 1.30.6 and 1.31.8 answer an empty 400 (tls). The request reaches no service, though it carries a token the + // check allows, so under client_address connection a file with tls can tell the check https, the listener's + // scheme, written as text (filter-ext-authz.yaml). + {name: "plain HTTP sent to the TLS port", keys: serverKeys, + send: request{proto: "http/1.1", method: "GET", host: "localhost", path: "/products/1", raw: true, plain: true, + headers: map[string]string{"authorization": "Bearer allow", "x-api-key": "key"}}, + want: answer{refused: true}, + by: map[string]own{"nginx": {difference: "tls", literal: literal{want: answer{status: 400}}}}}, }} // serverKeys are what the rows of a client's TLS offer depend on: a listener that speaks TLS. @@ -1499,15 +1508,17 @@ var auth = scenario{name: "auth", headers: map[string]string{"authorization": "Bearer allow", "x-api-key": "key"}}, want: answer{status: 200, service: "shop", received: map[string]string{"x-user-check": "GET /products/1?i={i} action= reports= country="}}}, // What a client could send past the check. - // Under client_address connection nginx tells the check the connection's scheme, whatever scheme the target - // names, so https over TLS on nginx-auth and portable, where the Envoy output tells the target's. + // Under client_address connection the check and the service are told the connection's scheme, whatever scheme + // the target names, so https over TLS, and under forwarded, on two-checks, nginx-checks and nginx-tracing, the + // check is told the target's http. {name: "an absolute target's host is the host the check is told, whatever the Host header", keys: []string{"auth.ask", "auth.accept"}, send: request{proto: "http/1.1", host: "127.0.0.1", line: "GET http://localhost/products/1 HTTP/1.1", raw: true, headers: map[string]string{"authorization": "Bearer report-forwarded", "x-api-key": "key"}}, - want: answer{status: 200, service: "shop", host: "localhost", received: map[string]string{"x-user-check": "proto=http host=localhost"}}, - by: map[string]own{"haproxy": {difference: lineRow, literal: literal{want: answer{status: 400}}}, - "nginx": {difference: "auth.send_request", files: []string{"nginx-auth", "portable"}, literal: literal{want: answer{status: 200, - service: "shop", host: "localhost", received: map[string]string{"x-user-check": "proto=https host=localhost"}}}}}}, + want: answer{status: 200, service: "shop", host: "localhost", received: map[string]string{"x-user-check": "proto=https host=localhost", + "x-forwarded-proto": "https"}}, + on: onEach([]string{"two-checks", "nginx-checks", "nginx-tracing"}, literal{want: answer{status: 200, service: "shop", + host: "localhost", received: map[string]string{"x-user-check": "proto=http host=localhost"}}}), + by: map[string]own{"haproxy": {difference: lineRow, literal: literal{want: answer{status: 400}}}}}, {name: "a client's own user, question and unchecked mark do not reach the service when the check allows with none of them", keys: []string{"auth.ask", "auth.accept"}, send: request{proto: "http/1.1", method: "GET", host: "localhost", path: "/products/1", forgedMark: true, @@ -1619,15 +1630,16 @@ var auth = scenario{name: "auth", literal: literal{want: answer{status: 200, service: "shop", path: "/products/%22x", received: map[string]string{"x-user-check": `GET /products/"x action= reports= country=`}}}, other: &own{difference: "routes[].pattern", files: checkedPatternFiles, literal: literal{want: answer{status: 400}}}}}}, - // An HTTP/2 :scheme that differs from the connection's, which a client in front may send. + // An HTTP/2 :scheme that differs from the connection's, which a client in front may send. Under client_address + // connection the check and the service are told the connection's scheme, so https over TLS, and under + // forwarded, on two-checks, nginx-checks and nginx-tracing, the check is told the :scheme http. {name: "an HTTP/2 request with :scheme http", keys: []string{"auth.ask", "auth.accept", "auth.send_request"}, send: request{proto: "h2", method: "GET", host: "localhost", path: "/products/1", raw: true, scheme: "http", headers: map[string]string{"authorization": "Bearer report-forwarded", "x-api-key": "key"}}, - want: answer{status: 200, service: "shop", received: map[string]string{"x-user-check": "proto=http host=localhost"}}, - by: map[string]own{"nginx": {difference: "auth.send_request", files: []string{"nginx-auth", "portable"}, - literal: literal{want: answer{status: 200, service: "shop", received: map[string]string{"x-user-check": "proto=https host=localhost"}}}}, - "haproxy": {difference: "auth.send_request", files: []string{"haproxy-file"}, - literal: literal{want: answer{status: 200, service: "shop", received: map[string]string{"x-user-check": "proto=https host=localhost"}}}}}}, + want: answer{status: 200, service: "shop", received: map[string]string{"x-user-check": "proto=https host=localhost", + "x-forwarded-proto": "https"}}, + on: onEach([]string{"two-checks", "nginx-checks", "nginx-tracing"}, literal{want: answer{status: 200, service: "shop", + received: map[string]string{"x-user-check": "proto=http host=localhost"}}})}, {name: "an HTTP/2 request with :scheme https", keys: []string{"auth.ask", "auth.accept", "auth.send_request"}, send: request{proto: "h2", method: "GET", host: "localhost", path: "/products/1", raw: true, scheme: "https", headers: map[string]string{"authorization": "Bearer report-forwarded", "x-api-key": "key"}}, @@ -1799,17 +1811,22 @@ var refusedUnderAllow = map[string]own{ // toldScheme: measured on Envoy 1.40.2 beside nginx 1.30.6 and 1.31.8 and HAProxy 3.2.26 and 3.4.7. Each row asks the // check, which reports the scheme it was told, and the service reports the x-forwarded-proto it received. The rows -// whose keys hold client_address run on the files with client_address connection and send_request; the others on every -// file with send_request too, two-checks, nginx-checks and nginx-tracing among them, which write no tls and take -// forwarded. nginx-connection writes connection and no tls, so it is sent over plain HTTP. +// whose keys hold client_address run on the files with client_address connection and send_request: full, portable, +// nginx-auth and haproxy-file, which write tls, and connection.yaml, which writes none, so it is sent over plain HTTP. +// The others run on every file with send_request, two-checks, nginx-checks and nginx-tracing among them, which write no +// tls and take forwarded. // -// Under connection a client's own x-forwarded-proto, https or ftp, is replaced by the connection's scheme for the -// check and the service, by every proxy. An absolute https target over TLS is served and told https, but by HAProxy, -// which answers every absolute target 400 over HTTP/1.1; over plain HTTP, on nginx-connection, the Envoy output answers -// it 403 and asks no check, and nginx serves it, a way nginx is less strict that its list names, and tells the check -// http, the scheme the service is sent. An HTTP/2 request with :scheme https sent over plain HTTP on nginx-connection -// is told https by the Envoy output, while the service is sent http: it tells the check the :scheme, whatever the -// connection, where nginx, whose variables hold no :scheme, tells the connection's (auth.send_request). +// Under connection every proxy tells the check the connection's scheme, the one the service is sent, whatever the +// client writes: the scheme of an absolute target, in any letter case, an HTTP/2 :scheme, ftp among them, or its own +// x-forwarded-proto of http, https or ftp. Here each way names https, the scheme other than the connection's on +// connection.yaml, and x-forwarded-proto names http too, the other scheme over TLS; the auth scenario's rows "an +// absolute target's host is the host the check is told, whatever the Host header" and "an HTTP/2 request with :scheme +// http" send the request line and the :scheme naming http over TLS, and want the check and the service told https. +// HAProxy's public listener answers every absolute target 400 over HTTP/1.1, and over plain HTTP the Envoy output +// answers an absolute https target 403, HTTPS:// too (its codec's https_url_on_plaintext_connection, which compares the +// scheme in any letter case); neither asks the check, as the same request with a token the check denies shows, which a +// proxy that asks the check answers 401. nginx serves that https target, in either letter case, and tells the check +// http, a way nginx is less strict that its list names. // // Under forwarded an absolute https target sent with x-forwarded-proto http is told https by the Envoy output and nginx, // the target's scheme before the header, while the service is sent the header's http, and an HTTP/2 :scheme https @@ -1818,51 +1835,83 @@ var refusedUnderAllow = map[string]own{ // connection's scheme, http, where nginx and HAProxy tell it ftp as written (auth.send_request). var toldScheme = scenario{name: "the scheme the check is told", exchanges: []exchange{ - {name: "an absolute https target", keys: []string{"client_address", "auth.ask", "auth.accept", "auth.send_request"}, + {name: "an absolute https target", keys: connectionKeys, send: request{proto: "http/1.1", host: "localhost", line: "GET https://localhost/products/1 HTTP/1.1", raw: true, headers: map[string]string{"authorization": "Bearer report-forwarded", "x-api-key": "key"}}, want: answer{status: 200, service: "shop", host: "localhost", received: map[string]string{"x-user-check": "proto=https host=localhost"}}, - on: map[string]literal{"nginx-connection": {want: answer{status: 403}}}, + on: map[string]literal{"connection": {want: answer{status: 403}}}, by: map[string]own{"haproxy": {difference: lineRow, literal: literal{want: answer{status: 400}}}, - "nginx": {difference: "client_address", files: []string{"nginx-connection"}, literal: literal{want: answer{status: 200, + "nginx": {difference: "client_address", files: []string{"connection"}, literal: literal{want: answer{status: 200, service: "shop", host: "localhost", received: map[string]string{"x-user-check": "proto=http host=localhost"}}}}}}, - {name: "an HTTP/2 request with :scheme https under connection", keys: []string{"client_address", "auth.ask", "auth.accept", "auth.send_request"}, + {name: "an absolute https target with a token the check denies", keys: connectionKeys, + send: request{proto: "http/1.1", host: "localhost", line: "GET https://localhost/products/1 HTTP/1.1", raw: true, + headers: map[string]string{"authorization": "Bearer deny-401", "x-api-key": "key"}}, + want: answer{status: 401}, + on: map[string]literal{"connection": {want: answer{status: 403}}}, + by: map[string]own{"haproxy": {difference: lineRow, literal: literal{want: answer{status: 400}}}, + "nginx": {difference: "client_address", files: []string{"connection"}, literal: literal{want: answer{status: 401}}}}}, + {name: "an absolute http target with a token the check denies", keys: connectionKeys, + send: request{proto: "http/1.1", host: "localhost", line: "GET http://localhost/products/1 HTTP/1.1", raw: true, + headers: map[string]string{"authorization": "Bearer deny-401", "x-api-key": "key"}}, + want: answer{status: 401}, + by: map[string]own{"haproxy": {difference: lineRow, literal: literal{want: answer{status: 400}}}}}, + {name: "an absolute HTTPS target in capitals", keys: connectionKeys, + send: request{proto: "http/1.1", host: "localhost", line: "GET HTTPS://localhost/products/1 HTTP/1.1", raw: true, + headers: schemeReport("")}, + want: withHost(toldTo("https", "https")), + on: map[string]literal{"connection": {want: answer{status: 403}}}, + by: map[string]own{"haproxy": {difference: lineRow, literal: literal{want: answer{status: 400}}}, + "nginx": {difference: "client_address", files: []string{"connection"}, literal: literal{want: withHost(toldTo("http", "http"))}}}}, + {name: "an HTTP/2 request with :scheme https under connection", keys: connectionKeys, send: request{proto: "h2", method: "GET", host: "localhost", path: "/products/1", raw: true, scheme: "https", headers: schemeReport("")}, want: toldTo("https", "https"), - on: map[string]literal{"nginx-connection": {want: toldTo("https", "http")}}, - by: map[string]own{"nginx": {difference: "auth.send_request", files: []string{"nginx-connection"}, - literal: literal{want: toldTo("http", "http")}}}}, - {name: "a client's own x-forwarded-proto https under connection", keys: []string{"client_address", "auth.ask", "auth.accept", "auth.send_request"}, + on: map[string]literal{"connection": {want: toldTo("http", "http")}}}, + {name: "an HTTP/2 request with :scheme ftp under connection", keys: connectionKeys, + send: request{proto: "h2", method: "GET", host: "localhost", path: "/products/1", raw: true, scheme: "ftp", + headers: schemeReport("")}, + want: toldTo("https", "https"), + on: map[string]literal{"connection": {want: toldTo("http", "http")}}}, + {name: "a client's own x-forwarded-proto https under connection", keys: connectionKeys, send: request{proto: "http/1.1", method: "GET", host: "localhost", path: "/products/1", headers: schemeReport("https")}, want: toldTo("https", "https"), - on: map[string]literal{"nginx-connection": {want: toldTo("http", "http")}}}, + on: map[string]literal{"connection": {want: toldTo("http", "http")}}}, + {name: "a client's own x-forwarded-proto http under connection", keys: connectionKeys, + send: request{proto: "http/1.1", method: "GET", host: "localhost", path: "/products/1", headers: schemeReport("http")}, + want: toldTo("https", "https"), + on: map[string]literal{"connection": {want: toldTo("http", "http")}}}, {name: "an absolute https target sent with x-forwarded-proto http", keys: []string{"auth.ask", "auth.accept", "auth.send_request"}, send: request{proto: "http/1.1", host: "localhost", line: "GET https://localhost/products/1 HTTP/1.1", raw: true, headers: schemeReport("http")}, want: withHost(toldTo("https", "https")), on: map[string]literal{"two-checks": {want: withHost(toldTo("https", "http"))}, "nginx-checks": {want: withHost(toldTo("https", "http"))}, - "nginx-tracing": {want: withHost(toldTo("https", "http"))}, "nginx-connection": {want: answer{status: 403}}}, + "nginx-tracing": {want: withHost(toldTo("https", "http"))}, "connection": {want: answer{status: 403}}}, by: map[string]own{"haproxy": {difference: lineRow, literal: literal{want: answer{status: 400}}}, - "nginx": {difference: "client_address", files: []string{"nginx-connection"}, literal: literal{want: withHost(toldTo("http", "http"))}}}}, + "nginx": {difference: "client_address", files: []string{"connection"}, literal: literal{want: withHost(toldTo("http", "http"))}}}}, {name: "an HTTP/2 request with :scheme https sent with x-forwarded-proto http", keys: []string{"auth.ask", "auth.accept", "auth.send_request"}, send: request{proto: "h2", method: "GET", host: "localhost", path: "/products/1", raw: true, scheme: "https", headers: schemeReport("http")}, want: toldTo("https", "https"), - on: onEach([]string{"two-checks", "nginx-checks", "nginx-tracing", "nginx-connection"}, literal{want: toldTo("https", "http")}), - by: map[string]own{"nginx": {difference: "auth.send_request", files: []string{"nginx-checks", "nginx-tracing", "nginx-connection"}, + on: map[string]literal{"two-checks": {want: toldTo("https", "http")}, "nginx-checks": {want: toldTo("https", "http")}, + "nginx-tracing": {want: toldTo("https", "http")}, "connection": {want: toldTo("http", "http")}}, + by: map[string]own{"nginx": {difference: "auth.send_request", files: []string{"nginx-checks", "nginx-tracing"}, literal: literal{want: toldTo("http", "http")}}, "haproxy": {difference: "auth.send_request", files: []string{"two-checks"}, literal: literal{want: toldTo("http", "http")}}}}, {name: "an x-forwarded-proto that is neither http nor https", keys: []string{"auth.ask", "auth.accept", "auth.send_request"}, send: request{proto: "http/1.1", method: "GET", host: "localhost", path: "/products/1", headers: schemeReport("ftp")}, want: toldTo("https", "https"), on: map[string]literal{"two-checks": {want: toldTo("http", "ftp")}, "nginx-checks": {want: toldTo("http", "ftp")}, - "nginx-tracing": {want: toldTo("http", "ftp")}, "nginx-connection": {want: toldTo("http", "http")}}, + "nginx-tracing": {want: toldTo("http", "ftp")}, "connection": {want: toldTo("http", "http")}}, by: map[string]own{"nginx": {difference: "auth.send_request", files: []string{"nginx-checks", "nginx-tracing"}, literal: literal{want: toldTo("ftp", "ftp")}}, "haproxy": {difference: "auth.send_request", files: []string{"two-checks"}, literal: literal{want: toldTo("ftp", "ftp")}}}}, }} +// connectionKeys are what the rows of toldScheme under client_address connection depend on: the connection's scheme +// is the check's word only with that key (client_address), and the check reports it (auth.ask, auth.send_request) in a +// header its answer echoes to the service (auth.accept). +var connectionKeys = []string{"client_address", "auth.ask", "auth.accept", "auth.send_request"} + // schemeReport is the headers of a request the check answers with the scheme it was told (report-forwarded), with the // client's own x-forwarded-proto when forwardedProto is not empty. func schemeReport(forwardedProto string) map[string]string { diff --git a/conformance/targets_haproxy_test.go b/conformance/targets_haproxy_test.go index 48146a1..94b27c2 100644 --- a/conformance/targets_haproxy_test.go +++ b/conformance/targets_haproxy_test.go @@ -37,8 +37,9 @@ const rateMainRow = "requests and burst are admitted, then the route refuses" // addresses that refuses such a request and one of the keys HAProxy writes with its own directives, then // examples/full and examples/portable, the files Envoy's entry runs: examples/full's committed haproxy.refused is // checked by its render alone, and examples/portable is loaded with no row on it, as its rows assert the Envoy output's -// answers to keys HAProxy writes with its own features. Last comes HAProxy's file of the connection limit -// (haproxyLimitsFile). The admin listener answers /ready on 127.0.0.1 only, as Envoy's does. +// answers to keys HAProxy writes with its own features. Then come HAProxy's file of the connection limit +// (haproxyLimitsFile) and, last, the file with client_address connection and no tls (connectionFile). The admin +// listener answers /ready on 127.0.0.1 only, as Envoy's does. func haproxyEntries(t testing.TB) []target { haproxy, _ := render.TargetNamed("haproxy") var entries []target @@ -53,6 +54,7 @@ func haproxyEntries(t testing.TB) []target { {label: "full", proxyfile: "../examples/full/hocon/Proxyfile"}, {label: "portable", proxyfile: "../examples/portable/hocon/Proxyfile", scenarios: []string{}}, haproxyLimitsFile, + connectionFile, }, mainRows: haproxyMainRows, image: p.image, diff --git a/conformance/targets_test.go b/conformance/targets_test.go index 480a49b..824d406 100644 --- a/conformance/targets_test.go +++ b/conformance/targets_test.go @@ -58,10 +58,10 @@ var ( // limitsFile is the battery's file for the connection limit, which Envoy's entry and each plain nginx entry run; it // runs the rows of that scenario alone, as no other row is there for its limit of two. limitsFile = file{label: "nginx-limits", proxyfile: "testdata/nginx-limits.yaml", scenarios: []string{backendLimits.name}} - // connectionFile is the battery's file with client_address connection and no tls, which Envoy's entry and each plain - // nginx entry run; it runs the rows of the scheme the check is told alone, as no other row is there for plain HTTP - // under connection. - connectionFile = file{label: "nginx-connection", proxyfile: "testdata/nginx-connection.yaml", scenarios: []string{toldScheme.name}} + // connectionFile is the battery's file with client_address connection and no tls, which Envoy's entry, each plain + // nginx entry and each HAProxy entry run; it runs the rows of the scheme the check is told alone, as no other row is + // there for plain HTTP under connection. + connectionFile = file{label: "connection", proxyfile: "testdata/connection.yaml", scenarios: []string{toldScheme.name}} ) // haproxyLimitsFile is the battery's file for HAProxy's connection limit, which Envoy's entry and each HAProxy entry diff --git a/conformance/testdata/connection.yaml b/conformance/testdata/connection.yaml new file mode 100644 index 0000000..da93186 --- /dev/null +++ b/conformance/testdata/connection.yaml @@ -0,0 +1,27 @@ +# The conformance battery's file with client_address: connection and no tls, so the clients speak plain HTTP: the +# auth check under deny at one check address, asked of a request with an x-api-key header, accepting x-user-check, +# with send_request: true, and one route to shop. It runs the scenario of the scheme the check is told alone, so its +# rows show what each proxy tells the check over plain HTTP: an absolute https target, in either letter case, which the +# Envoy output answers 403, HAProxy 400 and nginx serves, an HTTP/2 request with :scheme https or ftp and a client's own +# x-forwarded-proto. Envoy's entry, each nginx entry on the plain image and each HAProxy entry run it, and each literal +# on it is Envoy's measured answer. +listen: 10000 +admin: 9901 +client_address: connection +services: + shop: + http: 8080 + addresses: ["10.0.1.11", "10.0.1.12"] + checks: {http: 7070, address: "10.0.3.31"} +auth: + ask: checks /auth/check + timeout: 1500ms + enabled: true + when_unavailable: deny + only_with_header: x-api-key + accept: [x-user-check] + send_request: true +origins: + local: {hosts: [127.0.0.1, localhost]} +routes: + - {name: shop, prefix: /, to: shop} diff --git a/conformance/testdata/nginx-connection.yaml b/conformance/testdata/nginx-connection.yaml deleted file mode 100644 index 0a0b3f2..0000000 --- a/conformance/testdata/nginx-connection.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# The conformance battery's file for nginx with client_address: connection and no tls, so the clients speak plain -# HTTP: the auth check under deny at one check address, asked of a request with an x-api-key header, accepting -# x-user-check, with send_request: true, and one route to shop. It runs the scenario of the scheme the check is told -# alone, so its rows show what each proxy tells the check over plain HTTP: an absolute https target, which the Envoy -# output answers 403 and nginx serves, an HTTP/2 request with :scheme https and a client's own x-forwarded-proto. -# Envoy's entry runs it too, so each literal on it is Envoy's measured answer. -listen: 10000 -admin: 9901 -client_address: connection -services: - shop: - http: 8080 - addresses: ["10.0.1.11", "10.0.1.12"] - checks: {http: 7070, address: "10.0.3.31"} -auth: - ask: checks /auth/check - timeout: 1500ms - enabled: true - when_unavailable: deny - only_with_header: x-api-key - accept: [x-user-check] - send_request: true -origins: - local: {hosts: [127.0.0.1, localhost]} -routes: - - {name: shop, prefix: /, to: shop} diff --git a/docs/auth.md b/docs/auth.md index d41ddc8..bb6c1af 100644 --- a/docs/auth.md +++ b/docs/auth.md @@ -77,21 +77,18 @@ read: The request the check receives still goes to the path of `ask`. The proxy sets each of the four headers itself, so a client's own `x-forwarded-uri`, `x-forwarded-method` and `x-forwarded-host` never reach the check, also when `send` names them. Whose word the scheme is depends on [`client_address`](listener.md#the-clients-address). With -`connection` it is the connection's own, the scheme the service is sent, but the Envoy output tells the check an HTTP/2 -request's `:scheme`: `https` for a request sent over plain HTTP with `:scheme https`, though the service is sent -`http`, and `http` for one sent over TLS with `:scheme http`. It also tells `http` for a request sent over TLS whose -absolute target says `http`, and answers `403` to an absolute `https` target sent over plain HTTP, which the nginx file -serves and tells the check `http`. With `forwarded`, the default in a file without `tls`, it is the scheme of an -absolute target when the request line holds one, and through the Envoy output an HTTP/2 request's `:scheme`, then the -`X-Forwarded-Proto` the request arrived with, and the connection's scheme when it arrived with none; the service is -sent that header, or the connection's scheme. A proxy in front sets the header, but the client writes the request -line, and a client that reaches the gateway directly writes the header too, so the check then reads `https` for a -request sent over plain HTTP. For an `X-Forwarded-Proto` of `ftp` the Envoy output tells the check the connection's -scheme, where the nginx and HAProxy files tell it `ftp`, as it arrived. A gateway that faces its clients writes -`client_address: connection`, and a check behind the Envoy output can trust an `https` it is told only with `tls`, as a -client can send `:scheme https` over plain HTTP. The proxy sets `x-forwarded-uri`, `x-forwarded-method` and -`x-forwarded-host` on the check's request alone: a client's own copies reach the service as sent, unless -`remove_from_clients` names them. +`connection` it is the connection's own, the scheme the service is sent, whatever the client writes in the request +line, an HTTP/2 `:scheme` or its own `X-Forwarded-Proto`, so a gateway that faces its clients writes +`client_address: connection` and its check can trust the scheme it is told. With `forwarded`, the default in a file +without `tls`, it is, through the Envoy output and the nginx file, the scheme of an absolute target when the request +line holds one, which the HAProxy file answers `400`, and through the Envoy output an HTTP/2 request's `:scheme`, then +the `X-Forwarded-Proto` the request arrived with, and the connection's scheme when it arrived with none; the service is +sent that header, or the connection's scheme. A proxy in front sets the header, but the client writes the request line, +and a client that reaches the gateway directly writes the header too, so the check then reads `https` for a request +sent over plain HTTP. With `forwarded`, for an `X-Forwarded-Proto` of `ftp` the Envoy output tells the check the +connection's scheme, where the nginx and HAProxy files tell it `ftp`, as it arrived. The proxy sets +`x-forwarded-uri`, `x-forwarded-method` and `x-forwarded-host` on the check's request alone: a client's own copies +reach the service as sent, unless `remove_from_clients` names them. The proxy normalises every request's path before anything reads it, with or without `send_request` ([A route with `auth: off`](#a-route-with-auth-off) says why): dot segments are resolved, repeated slashes merged and diff --git a/docs/commands.md b/docs/commands.md index dff4907..9de353d 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -28,9 +28,11 @@ counts the ways that output is less strict than the Envoy output, serving a requ or sending a service what the Envoy output would not, and names the page that lists them, with its exit code unchanged: + ``` -proxyfile render: this HAProxy configuration is less strict than the Envoy output in 11 ways; docs/haproxy.md lists them under "Where HAProxy is less strict than the Envoy output" +proxyfile render: this HAProxy configuration is less strict than the Envoy output in 12 ways; docs/haproxy.md lists them under "Where HAProxy is less strict than the Envoy output" ``` + nginx's line names [`docs/nginx.md`](nginx.md#where-nginx-is-less-strict-than-the-envoy-output), HAProxy's [`docs/haproxy.md`](haproxy.md#where-haproxy-is-less-strict-than-the-envoy-output). A render for Envoy prints no such diff --git a/docs/conformance.md b/docs/conformance.md index d3f2b5d..1baa92b 100644 --- a/docs/conformance.md +++ b/docs/conformance.md @@ -7,10 +7,10 @@ so the released program never carries them. It runs each target of this version: ## What the battery proves -Each entry of the battery is a proxy image and the proxyfiles it runs. Envoy's entry, `envoy-1.40`, runs fourteen: +Each entry of the battery is a proxy image and the proxyfiles it runs. Envoy's entry, `envoy-1.40`, runs these files: [`examples/full/hocon/Proxyfile`](../examples/full/hocon/Proxyfile), which writes every key but the few its opening comment names, [`examples/portable/hocon/Proxyfile`](../examples/portable/hocon/Proxyfile), which writes in the same -world only the keys every generator is to render alike, nginx's own eight files, +world only the keys every generator is to render alike, nginx's own files, [`conformance/testdata/nginx.yaml`](../conformance/testdata/nginx.yaml) and [`conformance/testdata/nginx-plain.yaml`](../conformance/testdata/nginx-plain.yaml), the same with no pattern route, and, with an auth check, [`conformance/testdata/nginx-checks.yaml`](../conformance/testdata/nginx-checks.yaml) and @@ -18,24 +18,26 @@ with an auth check, [`conformance/testdata/nginx-checks.yaml`](../conformance/te [`conformance/testdata/nginx-tracing.yaml`](../conformance/testdata/nginx-tracing.yaml) and [`conformance/testdata/nginx-tracing-by-name.yaml`](../conformance/testdata/nginx-tracing-by-name.yaml), its collector found by name, and, with a connection limit, -[`conformance/testdata/nginx-limits.yaml`](../conformance/testdata/nginx-limits.yaml), and, with `client_address: -connection` and no `tls`, [`conformance/testdata/nginx-connection.yaml`](../conformance/testdata/nginx-connection.yaml), -and HAProxy's own four, [`conformance/testdata/haproxy.yaml`](../conformance/testdata/haproxy.yaml), +[`conformance/testdata/nginx-limits.yaml`](../conformance/testdata/nginx-limits.yaml), HAProxy's own files, +[`conformance/testdata/haproxy.yaml`](../conformance/testdata/haproxy.yaml), [`conformance/testdata/two-checks.yaml`](../conformance/testdata/two-checks.yaml), [`conformance/testdata/haproxy-traffic.yaml`](../conformance/testdata/haproxy-traffic.yaml) and -[`conformance/testdata/haproxy-limits.yaml`](../conformance/testdata/haproxy-limits.yaml). -The nginx entries `nginx-1.30` and `nginx-1.31` run on the two images pinned in `scripts/nginx-images`, one entry for -each line, and run nginx's own files but the two with tracing, `examples/full`, which nginx refuses, and -`examples/portable`. The nginx entries `nginx-otel-1.30` and `nginx-otel-1.31` run on the two images pinned in -`scripts/nginx-otel-images`, the same nginx versions in the images tagged `-otel`, which carry nginx's OpenTelemetry -module, one entry for each line, and run the two files with tracing alone: a file with `tracing` loads that module, -which the plain images do not carry ([nginx](nginx.md#tracing)). Each line of `scripts/nginx-otel-images` names an image -tagged `-otel` and each line of the other files names one that is not, pinned by digest, as +[`conformance/testdata/haproxy-limits.yaml`](../conformance/testdata/haproxy-limits.yaml), and, with `client_address: +connection` and no `tls`, [`conformance/testdata/connection.yaml`](../conformance/testdata/connection.yaml), which +every entry runs but those on nginx's images tagged `-otel`. +The nginx entries `nginx-1.30` and `nginx-1.31` run on the images pinned in `scripts/nginx-images`, one entry for +each line, and run nginx's own files but those with tracing, `examples/full`, which nginx refuses, +`examples/portable` and `connection.yaml`. The nginx entries `nginx-otel-1.30` and `nginx-otel-1.31` run on the images +pinned in `scripts/nginx-otel-images`, the same nginx versions in the images tagged `-otel`, which carry nginx's +OpenTelemetry module, one entry for each line, and run the files with tracing alone: a file with `tracing` loads that +module, which the plain images do not carry ([nginx](nginx.md#tracing)). Each line of `scripts/nginx-otel-images` names +an image tagged `-otel` and each line of the other files names one that is not, pinned by digest, as `nginx:..-otel@sha256:` or the same without `-otel`; the battery stops before any container at a line that does not, and `scripts/pinned-images.sh` takes no image from such a file. -The HAProxy entries, `haproxy-3.2` and `haproxy-3.4`, run on the two images pinned in `scripts/haproxy-images`, one -entry for each line, and run HAProxy's own four files, `examples/full`, which HAProxy refuses, and `examples/portable`, -on which they run no row, as its rows assert the Envoy output's answers to keys HAProxy writes with its own features. +The HAProxy entries, `haproxy-3.2` and `haproxy-3.4`, run on the images pinned in `scripts/haproxy-images`, one +entry for each line, and run HAProxy's own files, `examples/full`, which HAProxy refuses, `examples/portable`, +on which they run no row, as its rows assert the Envoy output's answers to keys HAProxy writes with its own features, +and `connection.yaml`. Each file is rendered for the entry's target with `proxyfile render --target ` through the program's own command line, the path a user takes. The proxy then runs on the rendered file in its own image, among stub backends, and the same requests get the answers the format promises. @@ -92,12 +94,13 @@ nginx entry on the plain image run it. HAProxy's `haproxy-limits.yaml` writes th one address, so HAProxy's own `maxconn` on that server binds, and runs the row of the connection limit alone; Envoy's entry and each HAProxy entry run it. -nginx's `nginx-connection.yaml` writes `client_address: connection` with no `tls`, so its clients speak plain HTTP, the -auth check with `send_request: true` and one route to shop, and runs the rows of the scenario the scheme the check is -told alone, so they show what each proxy tells the check over plain HTTP under `connection`: an absolute `https` target, -which the Envoy output answers `403` and nginx serves, telling the check the connection's scheme, an HTTP/2 request -with `:scheme https`, which the Envoy output tells the check as `https`, and a client's own `x-forwarded-proto`. Envoy's -entry and each nginx entry on the plain image run it. +`connection.yaml` writes `client_address: connection` with no `tls`, so its clients speak plain HTTP, the auth check +with `send_request: true` and one route to shop, and runs the rows of the scenario the scheme the check is told alone, +so they show what each proxy tells the check over plain HTTP under `connection`: an absolute `https` target, in either +letter case, which the Envoy output answers `403` and HAProxy `400`, neither asking the check, and nginx serves, an +HTTP/2 request with `:scheme https` or `:scheme ftp` and a client's own `x-forwarded-proto`, each told `http`, the +connection's scheme, by every proxy. +Envoy's entry, each nginx entry on the plain image and each HAProxy entry run it. nginx's `nginx-checks.yaml` is `two-checks.yaml` for nginx: the same check service with two addresses, `when_unavailable: deny`, the `x-api-key` condition and `send_request: true`, with `remove_from_clients` naming `x-request-id` alone, because @@ -113,10 +116,10 @@ route is, so the rows of a retried request that the check allows, denies or cann measured on Envoy. `nginx-tracing.yaml` is `nginx-auth.yaml` with no `tls` and no `client_address`, so its clients speak plain HTTP and `forwarded` applies, and a row's own `x-request-id` reaches the draw that picks the requests traced, and with `tracing`: the `otel` provider sending its spans to the battery's collector at `10.0.3.40:4317` ([The -world](#the-world)), `sample: {rate: 5%}`, `path_in_url: true` and eleven tags, of each source the nginx generator +world](#the-world)), `sample: {rate: 5%}`, `path_in_url: true` and tags of each source the nginx generator reads a tag from: an environment variable with a default, unset, and one set, `x-request-id`, a header with a default and one without, a header whose lines Envoy joins, the check's first `accept` name, a default holding `$`, `"` and `\`, -a tag named like a field of the Envoy output's span, `component`, and two of variables named like a property every +a tag named like a field of the Envoy output's span, `component`, and tags of variables named like a property every object has, `constructor`, unset, and `toString`, set. Envoy's entry runs it too, so each literal of its rows is measured on Envoy. `nginx-tracing-by-name.yaml` is the same tracing with the collector named `collector.internal.example:4317` and `dns.resolver` naming the battery's resolver, which gives that name the collector's address, so nginx sends its spans @@ -140,7 +143,9 @@ runs on no file of Envoy's entry, where its answers were measured, when a row ho carries or for a file the row does not run on, when a row that runs on a file of Envoy's runs on none of the files of a proxy version's entries while that target refuses none of the row's keys, when a key Envoy's rows exercise is exercised on none of the files of a version's entries while that target does not refuse it, and when a count of rows -this page gives below is not the number of rows the entries run. The entries of one version +this page gives is not the number the battery counts: the rows sent as their scenario starts, below, the rows each +entry runs on each file, in the passage that starts "The scenarios run in this order", and each scenario's rows on +each file of Envoy's entry, at the end of its line in the table of the scenarios. The entries of one version are judged together, nginx 1.31's on the plain image and on the image tagged `-otel` among them, and the entries of two versions never are. A row checks only what every proxy must answer: the status, which service and which of its backends answered and what it received (port, protocol, method, path, host and headers), the response headers that matter, @@ -148,30 +153,32 @@ answered and what it received (port, protocol, method, path, host and headers), difference that changes it (below); where two files give different answers, as the rate limit's count and a route only one file writes do, the row holds each file's answer. Every answer was measured on Envoy 1.40.2, and [`conformance/scenarios_test.go`](../conformance/scenarios_test.go) notes beside each scenario what Envoy also answers -that no row checks. A scenario's rows run one request at a time, but for the cost scenario's flood and fifteen rows that +that no row checks. A scenario's rows run one request at a time, but for the cost scenario's flood and 15 rows that wait for a proxy's timer or its close: a service that takes no connection within 5 s, a retried request and a retried -gRPC call whose every try times out connecting, the six rows over HTTP/2 that wait for Envoy to close the connection -after it refuses the request, and the six timeout rows; and 54 rows of the tracing scenario. Each of those sends its +gRPC call whose every try times out connecting, the rows over HTTP/2 that wait for Envoy to close the connection after +it refuses the request, and the timeout scenario's rows; and 56 rows of the tracing scenario. Each of those sends its request as its scenario starts, on connections of its own, and is checked once the scenario's other rows are done; the -next scenario starts only after the last of them ends. A row that reads spans, one of those 54 or a row in sequence, is +next scenario starts only after the last of them ends. A row that reads spans, one of those or a row in sequence, is judged once the scenario's rows in sequence are done, on the spans the collector held 6 s after the last request of the scenario's rows that read spans, and on those it holds 6 s later when its span is still missing or it wants none: nginx's exporter and the Envoy output's tracer each send the spans they hold every 5 s. On `full`, `portable`, -`nginx-file` and `nginx-auth`, which limit the catalog route to 20 requests a second, one row of the path normalisation -scenario waits one second before it is sent, so the route's bucket fills again between the 10 of the scenario's rows -that route serves before it and the 11 from it on, however fast a runner sends them; routing's and CORS's rows send it 9 -more before them, so 19 reach the route before that wait on `portable`, whose bucket holds 20. The scenarios run in this -order: in Envoy's entry 610 rows on `full`, 518 on `portable`, 349 on `nginx-file`, 259 on `nginx-plain`, 381 on -`nginx-checks`, 531 on `nginx-auth`, 576 on `nginx-tracing`, 39 on `nginx-tracing-by-name`, 3 on `nginx-limits` and 6 -on `nginx-connection`, nginx's own files, and 471 on `haproxy-file`, 364 on `two-checks`, 37 on `haproxy-traffic` and 1 -on `haproxy-limits`, HAProxy's own; in each nginx entry on the plain image 349 on `nginx-file`, 259 on `nginx-plain`, -381 on `nginx-checks`, 531 on `nginx-auth`, 518 on `portable`, 3 on `nginx-limits` and 6 on `nginx-connection`; in -each nginx entry on the image tagged `-otel` 576 on `nginx-tracing` and 39 on `nginx-tracing-by-name`; and in each -HAProxy entry 471 on `haproxy-file`, 364 on `two-checks`, 12 on `haproxy-traffic` and 1 on `haproxy-limits`. That is -4,145 rows in Envoy's entry, 2,047 in each nginx entry on the plain image, 615 in each nginx entry on the image tagged -`-otel` and 848 in each HAProxy entry, 11,165 in all, and each passes. The battery counts these rows before any -container starts and fails when one of these numbers is not what it counts. Before nginx wrote rate limits, RPC -retries, balance, hash and DNS names the same entries ran 3,041, +`nginx-file` and `nginx-auth`, which limit the catalog route to 20 requests a second, a row of the path normalisation +scenario waits a second before it is sent, so the route's bucket fills again between the scenario's rows that route +serves before it and those from it on, however fast a runner sends them; the comments beside those rows in +[`conformance/scenarios_test.go`](../conformance/scenarios_test.go) count the requests each part sends the route, with +those routing's and CORS's rows send it before them, against the 20 the bucket of `portable` holds. The scenarios run +in this order: in Envoy's entry 616 rows on `full`, 524 on `portable`, 350 on `nginx-file`, 259 on `nginx-plain`, 381 on +`nginx-checks`, 537 on `nginx-auth`, 576 on `nginx-tracing`, 39 on `nginx-tracing-by-name` and 3 on `nginx-limits`, +nginx's own files, 477 on `haproxy-file`, 364 on `two-checks`, 37 on `haproxy-traffic` and 1 on `haproxy-limits`, +HAProxy's own, and 11 on `connection`; in each nginx entry on the plain image 350 on `nginx-file`, 259 on +`nginx-plain`, 381 on `nginx-checks`, 537 on `nginx-auth`, 524 on `portable`, 3 on `nginx-limits` and 11 on +`connection`; in each nginx entry on the image tagged `-otel` 576 on `nginx-tracing` and 39 on +`nginx-tracing-by-name`; and in each HAProxy entry 477 on `haproxy-file`, 364 on `two-checks`, 12 on +`haproxy-traffic`, 1 on `haproxy-limits` and 11 on `connection`. That is 4,175 rows in Envoy's entry, 2,065 in each +nginx entry on the plain image, 615 in each nginx entry on the image tagged `-otel` and 865 in each HAProxy entry, +11,265 in all, and each passes. The battery counts these rows, and those each scenario's line in the table below +gives for each file of Envoy's entry, before any container starts, and fails when one of these numbers is not what +it counts. Before nginx wrote rate limits, RPC retries, balance, hash and DNS names the same entries ran 3,041, 1,310 and 791 rows: 40 rows were added, among them the scenarios client keys and hash, nginx's files gained the traffic keys those rows need, and each nginx entry runs `examples/portable`, where it ran no file of that world. Before nginx wrote HTTP retries they ran 3,273, 1,937 and 823: 13 rows were added, those of a retried route in the scenarios retry, @@ -196,33 +203,39 @@ with its own directives they ran 4,034, 2,009, 605 and 825: `haproxy-traffic.yam six in the scenario traffic keys and one in the scenario hash, `haproxy-limits.yaml` was added for the row of the connection limit, and `haproxy.yaml` gained a service found by DNS, so the row of `dns.resolver` runs on `haproxy-file`. Before nginx told the auth check the connection's scheme under `client_address: connection` and the -battery ran each proxy with two variables set they ran 4,102, 2,026, 610 and 839: `nginx-connection.yaml` was added -with the scenario the scheme the check is told, whose rows run on `full`, `portable`, `nginx-auth`, `haproxy-file` and -`nginx-connection`, and those whose keys hold no `client_address` on `two-checks`, `nginx-checks` and `nginx-tracing` -too, and two rows were added in the scenario tracing, each of an `env` tag whose variable is set, one -of them named like a property every object has, which run on `full` and `nginx-tracing`. In order: +battery ran each proxy with two variables set they ran 4,102, 2,026, 610 and 839: `connection.yaml` was added with the +scenario the scheme the check is told, whose rows run on `full`, `portable`, `nginx-auth`, `haproxy-file` and +`connection`, and those whose keys hold no `client_address` on `two-checks`, `nginx-checks` and `nginx-tracing` too, and +two rows were added in the scenario tracing, each of an `env` tag whose variable is set, one of them named like a +property every object has, which run on `full` and `nginx-tracing`. Before the Envoy output told the check the +connection's scheme under `client_address: connection` they +ran 4,145, 2,047, 615 and 848: each HAProxy entry runs `connection.yaml` too, five rows were added in the scenario +the scheme the check is told, an absolute `https` target and an absolute `http` target with a token the check denies, +an absolute target written `HTTPS://`, an HTTP/2 request with `:scheme ftp` and a client's own `x-forwarded-proto` of +`http`, which run on `full`, `portable`, `nginx-auth`, `haproxy-file` and `connection`, and one in the scenario mutual +TLS, plain HTTP sent to the TLS port, which runs on every file with `tls`. In order: | Scenario | Keys | What its rows check | |---|---|---| -| routing | `routes[].pattern`, `routes[].path`, `routes[].method`, `routes[].rewrite`, `routes[].prefix`, `routes[].to`, `services..http`, `services..addresses`, `services..address`, `services..host_header`, `dns.resolver`, `origins..hosts`, `client_address`, `tls.certificate`, `limits.request_headers.count`, `limits.request_headers.size` | A pattern route, and a path its pattern misses going to the prefix route; a path and method route with its rewrite, and another method going to the prefix route; a service whose address the resolver gives; the prefix route over HTTP/1.1 and over HTTP/2, where the service still hears HTTP/1.1; the host each service hears, `host_header`'s value for `accounts`; a host of another environment; `404` for a host no environment names, with no `content-type`, with `vary: Origin` and with an `x-request-id` the proxy makes; a service at its one address; a path compared by letter case, `/API/webhooks` going to the prefix route; the path `/_pf_auth`, written and with its underscore escaped, routed as any other; an escaped newline, `%0A`, at the end of a path and inside one, matched by the patterns as written and passed on as sent; an upgrade other than WebSocket answered `403`, and an `h2c` upgrade served as a plain request whose service receives no `upgrade` or `http2-settings`, which HAProxy answers `400`, a declared difference; the scheme the request came in on, in `x-forwarded-proto`; with `client_address = connection`, a client's own `x-forwarded-proto` replaced by the connection's scheme, and its own `x-envoy-external-address` and `x-request-id` by values the proxy writes; each of 32 requests that carry no `x-request-id` gets one the proxy makes, a version 4 UUID in lower case, 8-4-4-4-12 hexadecimal digits with the third group starting with `4` and the fourth with `8`, `9`, `a` or `b`, and the answer carries it too; `502` with no `content-type` for a service that refuses connections, and `502` with no body for a service that takes no connection within 5 s ("a service that takes no connection within 5 s is answered 502"), which only `nginx-plain` has, as its `hold` service behind the route `/hold/` ([The world](#the-world)): Envoy and nginx answer it after at least 4.95 s and under 5.95 s, the connect time of both with no `timeouts`, and every other file serves `/hold/x` from `shop`; a service's `X-Accel-Redirect` passed on to the client, not followed; a service's `Keep-Alive` not passed on to the client; the headers the Envoy output removes (`proxy-connection`, `x-forwarded-client-cert` and the `x-envoy-` headers that steer an Envoy) never reach the service; the host of an absolute request line, not the `Host` header, is the host the service hears, where HAProxy answers every absolute target `400`, a declared difference; an `Upgrade` that `Connection` does not name is removed and the request served; header names holding `_` or `.` reach the service; `TE: gzip, trailers` reaches it as `trailers`; `404` for a host with a dot at its end, with no `content-type`, as the `404` of an empty `X-Forwarded-Proto` and the `403` of an upgrade other than WebSocket from no origin; `400` for a method Envoy's parser does not know, with no `x-request-id`, and after the `400` of a byte above 0x7F in the target, of a header name holding `@` and of `HTTP/1.10` the connection closed, so a request written after it gets no answer, and after the `426` of `HTTP/1.9` and the `403` of an upgrade other than WebSocket, from no origin or a foreign one, closed too, where HAProxy keeps it and serves the request after the body, a declared difference; a `QUERY` with a `Content-Type` served and one with none answered `400`, over HTTP/1.1 and HTTP/2, the `400` with no `content-type` and no `x-request-id`, before the `404` of a host no environment names too; a `QUERY` whose `Content-Type` is spaces alone answered `400` over HTTP/1.1 and served over HTTP/2, where HAProxy answers it `400` over HTTP/2, a declared difference, and one whose `Content-Type` is a tab answered `400` over HTTP/1.1; a pattern's `{,3}` read as text, as RE2 reads it; a long path `((a|a)*c|a+b)` takes, which PCRE2 gives up on with the pattern as written, reaching its route; and a long path that makes PCRE2 give up on `(a|aa)+`, which goes on to the prefix route on Envoy and is answered `400` by nginx, a declared difference. A header name outside RFC 9110's token characters, `x@at`, `x(p)` or one holding the byte 0xFF, is answered `400` over HTTP/1.1 and refused over HTTP/2, where Envoy closes the connection and nginx answers `400`, a declared difference; the same requests, written by hand, with a name of token characters reach the service, and `x-ok`, `x_und` and `x.dot` reach it over both. A header value holding a control byte other than a tab is answered `400` over HTTP/1.1 and refused over HTTP/2, where Envoy closes the connection, HAProxy resets the stream and nginx answers `400`; a value holding a tab and UTF-8 reaches the service over both. A client that sends its request and closes its side of the connection before the service answers gets no answer: Envoy closes the connection, and HAProxy answers `400` or `403` or closes it. The row has its service hold its answer for 500 ms (`x-stub-delay`), because a proxy that reads the client's close after the service's answer passes the answer on: with a service that answered at once, a close sent with the request got no answer in 300 of 300 tries through Envoy and each nginx, and one sent 1 ms later got the service's `200` in 297 of 300 through Envoy and 300 of 300 through each nginx, so the row was a race, and it failed once in a whole run on nginx 1.31.8 and once on HAProxy 3.4.7. Under `client_address = forwarded`, an empty `X-Forwarded-Proto` from a client in front is answered `404` ("an empty X-Forwarded-Proto from a client in front is answered 404"), and with `connection` the request is served with the connection's scheme in its place; an `X-Forwarded-Proto` of spaces alone over HTTP/2 is served, where HAProxy answers `404`, a declared difference. A header written `x_forwarded_proto`, a name nginx reads as its own `X-Forwarded-Proto`, reaches the service as sent through Envoy and is answered `400` by nginx, a declared difference; `x_forwarded_for`, which nginx does not read as its own `X-Forwarded-For`, and a header named `constructor` or `__proto__`, over HTTP/1.1 and HTTP/2, reach the service as sent through both. Two `Accept` lines reach the service as one line through Envoy and as two lines through nginx, the same message, and two `Content-Type`, `User-Agent`, `Referer` or `If-Match` lines are joined and served by Envoy and answered `400` by nginx, each a declared difference on nginx's request-line row. With two or three spaces around an absolute target, the target's host is the host the service hears whatever the `Host` header says, and one that ends with a dot gets `404`; a tab after the method is served by Envoy and answered `400` by nginx, a declared difference; an absolute target whose host a query follows is refused. `TE: Trailers` reaches the service as `trailers` when `Connection` names `te` and is removed when it does not, and `Connection: close,` is served. An absolute target with an empty port, `http://localhost:/products/1`, is answered `400`. A chunked body's trailer reaches the service through no proxy, which receives the body; a trailer whose name holds `@` is answered `400` by Envoy and let through by nginx, which serves the body without it, and so is a trailer whose value holds a control byte, which HAProxy lets through too, over HTTP/1.1 and HTTP/2, and over HTTP/2 a trailer is served by Envoy and ends the connection on nginx, each a declared difference. A header line with no colon is answered `400` by Envoy and reaches the service through nginx as a header with an empty value, one of nginx's less strict ways. A header line folded onto the next, with a space or a tab, is served by Envoy and answered `400` by nginx and HAProxy, and a `Host` whose port is `99999` or `+1` is served by Envoy and answered `400` by nginx, declared differences. 100 header lines reach the service and 101 are refused (on `full` and `portable`, whose `limits.request_headers` admits 150, they reach it), and 96 header fields over HTTP/2 reach it, which nginx refuses, one field under Envoy's count, a declared difference, and 97 are refused ("97 header fields over HTTP 2 are refused", on the files that write `limits.request_headers.count`: Envoy resets the stream and nginx refuses the request, and `full` and `portable`, whose count is 150, serve them), and so are 96 beside `:authority` and a `host` field of the same value, which Envoy counts as two fields ("96 header fields over HTTP 2 beside :authority and a host field are refused", on the same files); HTTP/1.0 is answered `426`, with no `x-request-id`, and so are `HTTP/1.2`, `HTTP/1.9`, `HTTP/0.9` with headers, where nginx answers `400`, and `HTTP/2.0` on an HTTP/1 connection, where nginx answers `505`, and a request line with no version, where HAProxy answers `400` and nginx closes the connection, each a declared difference; `HTTP/1.10` and `HTTP/1.01` are answered `400`, and a method in lower case `400`; a header a `Connection` token names does not reach the service, where nginx and HAProxy answer `400`, a declared difference, and neither does `Keep-Alive`; `HTTP2-Settings` on a request that is no upgrade reaches the service; ten `Connection` tokens are answered `400` and nine served, a token and ten empty elements are served, where HAProxy answers `400`, a token and nine elements of white space are answered `400`, and ten tokens `close` are answered `400`, where HAProxy serves them, each a declared difference; a WebSocket over HTTP/2 is refused; over HTTP/2 an `:authority` with an empty port, `localhost:`, reaches the service as sent, where HAProxy sends `localhost`; two `Host` lines of one host are answered `404`, where HAProxy serves the request and nginx answers `400`; two `Content-Length` lines of one value, and `Content-Length` beside `Transfer-Encoding: chunked`, are answered `400`, and `Transfer-Encoding: gzip, chunked` `501`, where HAProxy serves the first two and answers the third `422`; a `POST` with no body reaches the service with `content-length: 0`, which neither nginx nor HAProxy sends; a WebSocket upgrade the service answers `200` without switching reaches the client with no body, where nginx and HAProxy pass the service's; a header of 20,000 bytes and a path of 20,000 bytes reach the service, where HAProxy answers `431` and `414`; on the files that write `limits.request_headers.size`, a head 64 bytes under the size, 61,376 bytes for the 60 KiB `nginx-file` writes, reaches the service as a header block ("a header block 64 bytes under the size", one header of 61,322 bytes) and as a request line ("a request line 64 bytes under the size", a path of `/products/` and 61,332 `a`), and a head one byte over Envoy's bound, 61,441 bytes, is refused: Envoy answers `431` to both, and nginx `400` to the header block ("a header block one byte over the size") and `414` to the request line ("a request line one byte over the size"), its own literal under `limits.request_headers.size`, while `full` and `portable` write 96 KiB and serve both; nginx reads a head of 61,376 bytes at most ([nginx](nginx.md#the-header-limits)), so the rows 64 bytes under have no margin on it; and over HTTP/2 a path of 7,000 bytes above 0x7F reaches the service, which HAProxy refuses and nginx answers `400` on `nginx-file`, each a declared difference; and a service that closes the connection of the first request a client sends on its connection before it answers is answered `502`, and so is one that closes, before its answer, a connection to `catalog` the proxy kept from a request on the client's same connection, over HTTP/1.1 and HTTP/2, the request reaching it once, where HAProxy sent it again before each request had a connection of its own. On `haproxy-file`, whose `test` environment has the hosts `.dot.example.com`, `dot.example.com.`, `-f`, `-i` and `-n`, a request to each reaches the service with that host, and on every other file it gets `404`. With `client_address = connection`, a client's `X-Forwarded-For` reaches the service on one line with the peer's address, and so do two lines of it, which Envoy joins, where nginx answers `400`, a declared difference, and the `x-envoy-` headers only a proxy in front may send (`x-envoy-decorator-operation`, `x-envoy-downstream-service-cluster`, `x-envoy-downstream-service-node`, `x-envoy-original-host`, `x-envoy-original-path`) do not reach it. The check location's own path, `/.proxyfile/check`, written or with its dot escaped, is routed as any other path and reaches `shop` as written, a prefix route's path without its slash, `/catalog`, is routed and not redirected, and a client that closes its side of the connection right after a request with a dot segment with a `;` parameter gets no answer, where nginx answers `400`, a declared difference. One hundred and forty-nine rows: all on `full`, `portable` and `nginx-file`, one hundred and forty-eight on `nginx-auth`, which writes no `dns.resolver`, one hundred and forty-three on `haproxy-file`, which writes no `limits.request_headers`, and one hundred and thirty on `nginx-plain`, `two-checks` and `nginx-checks`, which write no `dns.resolver`, no `limits.request_headers`, no pattern route and no `client_address`. | -| mutual TLS | `tls.certificate`, `tls.key`, `tls.clients.ca`, `origins..hosts` | A client with no certificate, one whose certificate another CA signed, and one whose certificate the clients CA signed and whose validity ended reach no service: the handshake fails, or the proxy refuses it, where nginx completes the handshake and answers an empty `400`, the difference nginx's row of `tls.clients.ca` names. A request whose TLS server name is one host of an environment and whose `Host` is another host of the same environment is served by Envoy and answered with an empty `421` by nginx, which asks for client certificates, a declared difference. The other CA carries the clients CA's name, so a proxy that matched the issuer by name would let it through. Every other row sends a client certificate the clients CA signed. A client that offers only TLS 1.1, a TLS 1.2 client that offers only a CBC suite, and one that offers only the group P-384 are refused in the handshake, and one that offers only the group X25519MLKEM768 is served. Eight rows, on every file but `nginx-plain`, `two-checks` and `nginx-checks`, which write no `tls`. | -| CORS | `cors.allow_methods`, `cors.allow_headers`, `cors.expose_headers`, `cors.max_age`, `origins..hosts`, `origins..origins`, `origins..patterns` | A preflight from a listed origin and one from an origin a pattern covers answer `200` with `access-control-allow-origin` and `access-control-max-age`; a preflight and a request from another origin answer `403`, and so does a request from another origin to a path ending `.html`, as `text/plain` on every proxy, whose own answers take no type from the path's ending; a request from a listed origin reaches the service with its `origin` and is answered with `access-control-allow-origin` and `access-control-expose-headers`. The preflight from a listed origin and the request from another origin carry a token the check denies and one the token filter refuses, each answered `401` alone, so on a file that writes the check their `200` and `403` show that the origin is decided before the token and the check. An origin on the environment's own host that neither list holds, `https://api.example.org` to `api.example.org`, is admitted without `access-control-allow-origin`: its request reaches the service and its preflight answers `200`. With no list, an origin on one of the environment's hosts is admitted and every other refused: a request with no `Origin`, and one from `http://localhost` over `http` or `https`, with a port, or from the environment's other host `http://127.0.0.1` reaches the service, and a preflight from `http://localhost` is answered `200` by the proxy; an origin on another environment's host, the host in capitals, with a trailing dot or with other characters for its dots, `null`, a present but empty `Origin`, a preflight from another origin and a WebSocket upgrade from one answer `403`, where HAProxy's parser answers that upgrade, which carries no `Sec-WebSocket-Key`, `400`, a declared difference. An empty `Origin` over HTTP/2 is answered `403` too, and an empty `Origin` line before or after the origin of the host, or a tab before that origin, changes nothing: the service receives the origin as one line. A preflight from a listed origin with no token is answered with the method and the headers it asks for; one from a listed origin in capitals is admitted with the origin as sent, and one from a pattern's origin in capitals is refused. The `Origin` header is read as one line: two `Origin` lines a pattern covers when joined are admitted with the joined line in `access-control-allow-origin`, where nginx answers `403`, a declared difference, two whose first is listed, two of the request's own origin, and one line holding a listed origin after a comma are refused, and an empty `Origin` line after a listed one is left out; a preflight that asks on two lines for two methods or for headers is answered with both, joined with a comma, and by nginx with a comma and a space, a declared difference. A listed origin with a trailing space is admitted, and the service receives it without the space. A service that is down, asked from a listed origin, is answered `502` with `access-control-allow-origin` and `access-control-expose-headers`, and a request from a listed origin to a host no environment names is answered `404` with no `access-control-allow-origin`. A refused path, a preflight to it, an upgrade other than WebSocket, a request with a NUL byte in a header from a listed origin and one with `Content-Length` beside `Transfer-Encoding: chunked` from it are answered with no `access-control-allow-origin`, where HAProxy serves the last with it, a declared difference, and a header line of 9,000 bytes from one is served with it by every proxy, nginx's header buffers reading a line as long as the header limit ([nginx](nginx.md#the-header-limits)). An admitted `Origin` of 600 bytes is echoed beside a service's answer of 100 KB, and so is one of 1,100 bytes, where HAProxy answers `403` before the service, a declared difference. A preflight from a listed origin to `/..;x/products/1`, with no token and with a token the check allows, is answered `200` by Envoy, which resolves the path and asks no check, and `400` by nginx and HAProxy, which with the token ask the check first, each a declared difference, and a denial of the check from a listed origin carries `access-control-allow-origin` and `access-control-expose-headers`. Fifty-two rows, all on `full`, `portable`, `haproxy-file` and `nginx-auth`, fifty on `nginx-file`, which writes no check, and nineteen on `nginx-plain`, `two-checks` and `nginx-checks`, which write no list of origins and no `cors`. | -| auth | `auth.ask`, `auth.only_with_header`, `auth.send`, `auth.accept`, `auth.send_request`, `auth.timeout`, `auth.when_unavailable`, `routes[].auth`, `remove_from_clients`, `auth.jwt.claims`, `services..host_header`, `cors.expose_headers`, `origins..origins`, `log` | A request with no `authorization` header reaches the service, which it could not if the check were asked; when the check allows, the service receives the check's headers `auth.accept` admits and not another, and what the check was told (the method, the path with its query, `x-country`), never the `x-forwarded-uri` and `x-forwarded-method` the client sent; the check's `401` and `403` reach the client, without the `x-envoy-upstream-service-time` Envoy's client for the check adds; a check that answers `503` lets the request through, as `when_unavailable = allow` says, and on `two-checks` and `nginx-checks`, whose `when_unavailable` is `deny`, gets `403`; the mark of a request the check could not answer reaches the service, and a client's own copy never does, whether the check allows or is not asked; a route with `auth = off` is not checked; a client's own copies of the headers `remove_from_clients` names, of the check's headers and question, and of the headers `auth.jwt.claims` sets never reach the service. A header `remove_from_clients` names does not reach the service when a client sends it on two lines, one with its name in capitals; a client's own `x-request-id` is replaced by another when `remove_from_clients` names it; and on `two-checks`, whose `remove_from_clients` names the prefix `ho*`, a client's `ho-x` does not reach the service and its `Host` does. The check is told it is internal and its deadline, `x-envoy-internal: true` and `x-envoy-expected-rq-timeout-ms: 1500`; a header sent on two lines reaches it as one line, joined with a comma; a client's own `x-forwarded-proto` reaches it under `forwarded`, and the connection's scheme under `connection`; it receives the `Host` the client sent whatever the check service's `host_header`; and the `only_with_header` header sent twice, an empty line before or after the token, asks it. A check's `201` is answered `403`, and a status of `600` is passed on as the check's own, where HAProxy and nginx answer `403`. A denial of 20,000 bytes, and one with a header of 50,000, reach the client, and an allowing answer whose `x-user-id` holds 20,000 bytes sets it on the request where `auth.accept` admits it, where HAProxy answers each `403`, a declared difference. An answer whose body breaks off, and one of 101 header lines, are a check that could not answer: the request is served with the mark under `allow` and answered `403` under `deny`. A `200` that RFC 9112 does not read whole is such a check for Envoy too, in nine forms: a `Content-Length` that is not a number, two `Content-Length` lines, a control byte in a header value, a status that is not three digits, a header name outside the token characters, `Content-Length` beside `Transfer-Encoding`, a chunk size that is not hexadecimal, a malformed header line in a `1xx` before it, and a malformed trailer line; HAProxy answers each `403` under `allow` too, a declared difference. Of 24 requests while `check-2`, one of the two check backends of `two-checks` and `nginx-checks`, refuses connections, at least one is answered `403` on those files: no other backend answers a check it refused. Rows for each form of an answer a check can write that RFC 9112 reads in a way of its own hold Envoy's reading, measured on Envoy 1.40.2: a status line of `2 0 0`, `20` or `000`, of `304` or of `101` is passed on as the check's own, and so is a denial with a folded header line; a status of `200.1`, `500`, `599`, or `503` with a body, a `200` with a header line with no colon, a header value with a vertical tab, `Transfer-Encoding: gzip, chunked`, or `identity` beside a `Content-Length`, a chunk that does not end its line, a space before a header's colon, a header name that holds a NUL or the byte `0xE9`, and a `Content-Length` past what any reader holds, are each a check that could not answer, and so is a denial with a header line with no colon; a `200` of `HTTP/2.0`, with two spaces after its version, with a space after a chunk's size, with spaces around its `Content-Length`, with a lone CR before a CRLF, with `_` in a header name, with bytes after its body, with a body of 1 MiB, or holding the relay's own header name `x-proxyfile-check`, is read as allowed. A denial with a body of 1 MiB, of 1 MiB and a byte and of 1,100,000 bytes reaches the client whole, and a denial's header that holds the byte `0xE9` reaches it as the check wrote it, and a denial with no body reaches it with no `content-type`. A `200` whose chunk-size line ends in a bare LF, or whose last chunk's line does, is a check that could not answer on Envoy, and a `200` whose chunk data, trailer line and final line end in a bare LF is read as allowed; nginx's relay and HAProxy's script refuse the first two under `allow` too, a declared difference. A `200` whose accepted header is folded reaches the service with the spaces and tabs of the fold, a tab, spaces on both lines or two folds, where HAProxy joins them by one space, a declared difference, and one whose accepted header is empty reaches the service empty. A `200` whose accepted header takes the request past the header size is answered `500`, where HAProxy answers `431`, a declared difference, and one whose accepted headers take it past the header count, 100 fields as Envoy counts them, is answered `500` by Envoy on every file but `full` and `portable`, which serve it, by nginx and by HAProxy, with an admitted origin's CORS answer, where one they take to the count is served: with `client_address: connection` the `x-forwarded-for` and `x-envoy-external-address` the proxy sets count too, so 87 lines from the client reach the count there and 91 elsewhere. A `200` that sets no accepted header is not counted, so with 96 numbered lines beside it the request is served by every proxy. With the accepted header and 91 numbered lines, a request with a chunked body is served, its `Transfer-Encoding` line not counted, and one with a body framed by its length is answered `500`, its `Content-Length` line counted, on `two-checks` and `nginx-checks`, where `haproxy-file` and `nginx-auth`, with three accepted headers and the two the proxy sets under `client_address: connection`, answer both `500` and `full` and `portable`, whose count is 150, serve both; and a gRPC call over HTTP/2 whose accepted header and 87 numbered fields take it past the count is answered `200` with `grpc-status` `2` and reaches no service, and one with 86 is served, where `haproxy-file` and `nginx-auth` answer 86 with `grpc-status` `2` too and `full` and `portable` serve both. nginx's relay reads some of these forms otherwise, and each such row holds nginx's own answer under `by`, named by the row of `auth.ask` or of `auth.when_unavailable` that declares it. Rows for how nginx asks the check hold Envoy's answer, and nginx's own where it declares a difference: the check location's own path asks the check as any other path does; an upload sent with `Expect: 100-continue` that the check refuses gets `100 Continue` first; a request with a body the check allows reaches the service with its body; a sent header that holds the byte `0xE9` reaches the check with a `!` for it, one that holds well-formed UTF-8 reaches it as sent, one that holds well-formed UTF-8 and then a byte that is not reaches it with a `!` for that byte, a header on two lines of characters outside ASCII reaches it as sent, joined by a comma, and a path of well-formed UTF-8 and then a byte that is not, over HTTP/2, is told to it escaped, as the service receives it; an `only_with_header` header sent as a lone tab is not asked; 100 checked streams at once on one HTTP/2 connection are each answered by their own check; an absolute target's host is the host the check is told, whatever the `Host` header; a client's own user, question and unchecked mark do not reach the service when the check allows with none of them, and the check receives none of a client's own removed header, user and mark; a dot segment with a `;` parameter asks the check first, and is answered `400` when the check allows; a denial of a request from a listed origin carries the CORS answer; a WebSocket upgrade the check allows reaches the service, and one it denies is answered with the denial; a header the check's answer sets on one request is not on the next request of the same connection, and a check's `2xx` other than `200` is answered at once on a kept-alive connection; a request the check denies, one whose check is unanswered and one whose check's status is passed on each have a body that holds a request read as a body, and the next request on the connection is answered, where nginx and HAProxy answer a status of `600` `403` and the unanswered one is `403` first on `two-checks` and `nginx-checks`; a client's own `x-proxyfile-method` and `x-proxyfile-path` change nothing the check is told; the check is told the path with an escaped letter, with a dot-dot segment and a query, with a query's escapes of unreserved and of reserved characters, and with a quote; an HTTP/2 request is told its `:scheme`; a client's `HTTP2-Settings` of an h2c upgrade does not reach the check, and with no upgrade it reaches it when `send` covers it; a check's redirect whose `Location` is a path reaches the client as the check sent it; and the request log holds how long a denied request's check took, no check time for a request with no `only_with_header` header, and an unanswered check for a request the check cannot answer under `allow`. A request to a retried route is checked once, before its first try: with one shop backend refusing connections, each of 20 requests the check allows reaches the other backend with the header the check accepted, each of 6 it denies is answered `403` with no service, and each of 10 whose check answers `503` reaches the other backend with the unchecked mark under `allow` and is answered `403` under `deny`. One hundred and fifty-two rows: all on `full`, one hundred and fifty-one on `nginx-auth`, which writes no `auth.jwt.claims`, one hundred and forty-eight on `portable`, which writes neither that nor `routes[].retries`, one hundred and forty-four on `haproxy-file`, which writes none of those and no `log`, one hundred and thirty-two on `nginx-checks`, which writes none of `auth.jwt.claims`, `auth.send` and `log`, no route with `auth = off` and no list of origins, one hundred and twenty-nine on `two-checks`, which writes no `routes[].retries` either, and the three rows of `remove_from_clients` also on `nginx-file` and `nginx-plain`, which write it and no check. | -| the scheme the check is told | `client_address`, `auth.ask`, `auth.accept`, `auth.send_request` | Each row asks the check, which reports the scheme it was told, and the service reports the `x-forwarded-proto` it received. Under `client_address: connection`: an absolute `https` target is served over TLS and told `https`, but by HAProxy, which answers an absolute target `400`, and on `nginx-connection`, over plain HTTP, the Envoy output answers it `403` and asks no check, and nginx serves it and tells the check and the service `http`, the connection's scheme; an HTTP/2 request with `:scheme https` is told `https` over TLS, and on `nginx-connection` the Envoy output tells the check `https` and sends the service `http`, where nginx tells both `http`, a declared difference; and a client's own `x-forwarded-proto` of `https` or `ftp` is replaced by the connection's scheme for the check and the service, by every proxy. Under `forwarded`, on `two-checks`, `nginx-checks` and `nginx-tracing`: an absolute `https` target sent with `x-forwarded-proto: http` is told `https`, the target's scheme, and the service is sent `http`, where HAProxy answers `400`; an HTTP/2 request with `:scheme https` sent with `x-forwarded-proto: http` is told `https` by the Envoy output and `http` by nginx and HAProxy, a declared difference, and the service is sent `http`; and an `x-forwarded-proto` of `ftp` reaches the service as sent, while the Envoy output tells the check `http`, the connection's scheme, and nginx and HAProxy tell it `ftp`, a declared difference, which nginx's list of ways it is less strict names. Each row runs on `full`, `portable`, `nginx-auth`, `haproxy-file` and `nginx-connection`, and the rows whose keys hold no `client_address` on `two-checks`, `nginx-checks` and `nginx-tracing` too. | -| timeout | `auth.timeout`, `auth.when_unavailable`, `timeouts.idle` | The check holds the request for 3 s, past `auth.timeout`'s 1500 ms, and its `401`, and its `200`, send their body of 100 bytes a byte every 100 ms, so it ends after 10 s. The request reaches the service with the mark of a request the check could not answer under `allow`, and is answered `403` under `deny`, on `two-checks` and `nginx-checks`, after at least 1.45 s and in under 2.95 s, 50 ms inside the two times because the row reads a different clock from the proxy's and the check's (below). Three rows, on `full`, `portable`, `haproxy-file`, `two-checks`, `nginx-checks` and `nginx-auth`. With `timeouts.idle`, 2 s on `nginx-file`, `nginx-auth` and `haproxy-traffic` and 90 s on `full` and `portable`, three rows more. In "a service silent past the idle time" the stub holds its answer for 3 s (`x-stub-delay: 3s`), and Envoy and nginx answer `504` as `text/plain`, Envoy's own text where nginx's own page would be `text/html`, after at least 1.95 s and under 2.95 s (measured at 2.002 to 2.005 s on Envoy 1.40.2 and on nginx), where `full` and `portable` serve it with `200` after 2.95 s or more. In "an answer that pauses less than the idle time" the stub sends the status and headers, then a space after each of two pauses of 1.25 s (`x-stub-trickle: 2x1250ms`), then its echo: each pause is 0.75 s under the idle time and the answer ends 0.5 s past it, so a limit on the whole answer would end it, and every proxy serves it with `200` after at least 2.45 s. In "a request body that pauses past the idle time" a `POST` with `Content-Length: 4` is sent by hand, `ab`, then `cd` after 3 s: Envoy answers `408` after at least 1.95 s, so the row shows the idle time ended it, where nginx closes the connection with no answer, a declared difference on `timeouts.idle`, and `full` and `portable` serve it with `200` and the body `abcd`. Each bound keeps 50 ms from the time it tests, for the two clocks, and the `504` comes within 1 s past the idle time, for a loaded runner. | -| retry | `routes[].retries`, `routes[].rpc.retries` | A request that reached the service is never tried again: a first try the service closes before any answer gives `502`, a gRPC call whose first try is reset gives `grpc-status` `14`, and a `503` from the service is passed on from its first try. A request whose connection a backend refused is tried again on the other: with one of the two shop backends refusing connections, 40 requests to the shop route and 40 gRPC calls to shop are each answered by the other backend; on `nginx-file`, whose shop route writes `retries: 0`, each of the 40 requests to the shop route is answered `502` with no service, as no other backend is tried, or by the backend that is up, and at least one of each, so a proxy that answered every request `502` would fail the row. On `nginx-plain`, whose rpc entry retries once and sends `example.hold.*` to the two backends that take no connection, a call is answered `200` with `grpc-status` `14` after at least 9.95 s and under 10.95 s, the two tries' connect time of 5 s each, and a request to its route `/held/`, which retries once to the same backends, `502` in the same bounds, which a script that found the route's time spent after the first try (`504` at 5 s) or a missing copy for the second try (`500`) fails; on the other files, which list no such method and no such route, both reach the shop route's service. A gRPC call that is not `POST`, a `GET` with gRPC's content type over HTTP/1.1 whose first try the service closes, is answered `200` with `grpc-status` `14` and not tried again. `nginx-auth`, `nginx-checks` and `nginx-plain`, whose shop routes write no retries, get `nginx-file`'s answers there. The rows of a retried route send to `/retried/products/1`, the route `/retried/` of `nginx-file`, `nginx-auth` and `nginx-checks` and the shop route of `full`, which retries; `nginx-plain` serves it by its shop route, which tries each request once, so there each answer is `502` or the other backend's, and at least one of each. nginx reads whole before the first try of a retried route a body with a length of at most 1 MiB and a request with no body, and sends any other, one in chunks among them, as it arrives and tries it once ([nginx](nginx.md#retries)). With one shop backend refusing connections, 40 requests are each answered by the other, and 40 `POST`s with neither `Content-Length` nor `Transfer-Encoding`; of 40 `GET`s whose 180,000 bytes come in one-byte chunks, each reaches the other backend whole through Envoy, which tries it again, and nginx answers `502` each one the refusing backend drew and serves the others, a declared difference; 40 `PUT`s of 1 MiB each reach it whole; of 40 `PUT`s of 1,048,577 bytes, one more than Envoy's buffer for a retry, at least one is answered `507` by Envoy and `502` by nginx, which tries it once, a declared difference; of 40 chunked `PUT`s, and of 40 over HTTP/2 with no content-length, at least one reaches the other backend with its body through Envoy, which tries again a body under its bound, and at least one is answered `502` by nginx, a declared difference. A row that needs the refusing backend drawn, or each backend, sends 40 requests, so a backend drawn at random is missed with a chance of 2^-40. A `PUT` whose first try the service closed once it arrived is answered `502` and not tried again, over HTTP/1.1 and over HTTP/2. A request whose every backend refuses is answered `502` and writes one upstream-failure line, with the flags `URX,UF`, its route and the status `502`, on Envoy and on both nginx versions; the line carries no request id, so the row finds it by route and status among the lines the proxy wrote after the row began. A `PUT` of 1,048,577 bytes with no backend refusing is served once, whole. Nineteen rows on `full` and `nginx-file`, fifteen on `nginx-auth`, which writes no rpc retries, fourteen on `nginx-checks`, which writes no `log` either, and eighteen on `nginx-plain`, which writes no `log`, and fifteen on `haproxy-traffic`, whose rpc entry writes no retries: `portable` writes no retries. | -| gRPC | `routes[].rpc`, `routes[].rpc.to`, `routes[].rpc.to.`, `routes[].rpc.to..service`, `rpc.methods`, `rpc.methods[].service`, `rpc.methods[].method`, `rpc.methods[].action`, `rpc.methods[].reports`, `services..grpc`, `auth.ask`, `auth.when_unavailable`, `log` | A method of a package mapped to `shop` reaches shop's gRPC port over HTTP/2 and answers `grpc-status` `0`; a method of any other package reaches `accounts`; the check is told a method's action and reports, and not an action the client sent, and the service receives neither; a gRPC service's `X-Accel-Redirect` is passed on, not followed; a call through a `..` segment reaches the method's path; a call whose service refuses the connection on every backend is answered `200` with `grpc-status` `14`, `content-type` `application/grpc` and no `grpc-message`; a call whose service resets its stream is answered the same, with Envoy's and HAProxy's `grpc-message` naming the reset, where nginx sends none, a declared difference, and a request that is not a gRPC call, sent to that route, `503` with Envoy's text, where nginx and HAProxy answer `502` with no body, a declared difference; a call the check denies is answered in gRPC's form, `200` with `grpc-status` `16` and the denial's body in `grpc-message`, percent-encoded where it holds a `%`, a letter outside ASCII or a line feed. A call the check denies with `403` is answered `200` with `grpc-status` `7`; a call the check cannot answer goes on with the unchecked mark under `allow`, and is answered `200` with `grpc-status` `7` under `deny`; a call whose check's answer cannot be read is a check that could not answer; and a call the check cannot answer logs an unanswered check with the method's action. A call whose accepted header the check sends empty reaches the service with that header empty, where nginx sends a gRPC service none, a declared difference. Sixteen rows: all on `full`, `portable` and `nginx-auth`, fifteen on `haproxy-file`, which writes no `log`, eleven on `two-checks` and `nginx-checks`, which write no `rpc.methods[].action`, and seven on `nginx-file` and `nginx-plain`, which write neither that nor `auth.ask`. | -| path normalisation | none: it is written for every file ([Written with no key](portability.md#written-with-no-key)) | `..`, `.`, `//`, `%2F` and `%2e%2e` in a path are resolved before a route is picked, and the service hears the normalised path; so are `..` followed by an escaped slash (`..%2f`), by a backslash written as `%5C`, and by a written backslash; `..;` and `.;`, written with dots, resolved as `..` and `.`, which nginx and HAProxy answer `400`, a declared difference; an exact path reached through `..`. An invalid escape, `%zz`, is passed on to the service, whose own `400` answers it, and nginx answers it `400` itself, a declared difference. An escaped `+` and an empty query reach the service as sent; an empty query after a path that needs normalising reaches it after the normalised path, and nginx answers it `400`, a declared difference. A path that still holds a dot segment with a `;` parameter after normalisation answers `400` and reaches no service, the `;` written or escaped once: `/catalog/%2e%2e;/products/1`; `..%3B` and `..%3b`; `.%3B` and `%2e%3b`; dots written escaped, in either case of hex, before an escaped `;`; an escaped `;` with a value or twice over; on the last segment and on the first; between backslashes, written or as `%5C`; and before an escaped slash. These reach the service as sent: a `;` parameter on an ordinary segment, on a name and on a name that starts with a dot; a `;` and an escaped `;` after three dots; an escaped `;` after a name that ends in two dots and inside a name; a `;` escaped twice after `..`; a query that holds `/..;/` or `/..%3B/`; and an escaped `?` after `..`. A dot segment with an escaped `;` that a `..` after it removes reaches the service resolved, and nginx answers it `400`, a declared difference. A path with an empty segment before a dot-dot segment, `/catalog//../products/1`, reaches `catalog` as `/catalog/products/1` through Envoy and HAProxy, where nginx answers `400`, a declared difference, and so does the same path with the slash escaped, `/catalog/%2F../products/1`, and over HTTP/2; an empty segment after a dot-dot segment, `/products/../catalog//items`, reaches `catalog` as `/catalog/items` through all three. After the `400` of a dot segment with an escaped `;`, sent with a body that holds a second request and then the client's next request in the same write, Envoy closes the connection and answers no next request, as nginx does, where HAProxy keeps the connection and answers the next request, a declared difference. Forty-seven rows. | -| the path as the client wrote it | none: it is written for every file ([Written with no key](portability.md#written-with-no-key)) | A path with nothing to normalise, or with only an escape Envoy keeps, is matched and reaches the service as written: `/api/x%3Bv=1/admin`, `/api/a%20b/admin`, `/u/%40bob`, `/l/a%20b` and `/api/a%7cb`, in the case of hex written, where nginx's and HAProxy's own files have patterns that would take the decoded character; `/x%C3%A9` is not taken by the pattern `^/x..$`; an empty query on such a path reaches the service as sent. A path that needs normalising and keeps no escape is matched and sent normalised. A raw `\|` reaches the service as `%7C`. nginx answers `400`, each a declared difference, to a path that needs normalising and keeps an escape, `/api/a%2fb%3bc`; to a byte Envoy escapes beside an escape; to a byte Envoy escapes on `nginx-file`, which has pattern routes; to an escape and to an empty query on a route with a `rewrite`; and to an empty query after a byte Envoy escapes. A `#` in the target is answered `400` over HTTP/1.1 and HTTP/2, where HAProxy resets the HTTP/2 stream, a declared difference, and so is one to a host no environment names, before its `404`. An escaped NUL, `%00`, in the path is answered `400`, and a byte above 0x7F sent raw over HTTP/2 reaches the service escaped, `%C3%A9` for `é`, which nginx answers `400` on `nginx-file`, a declared difference. Twenty-one rows. | -| an auth-off prefix route | `routes[].prefix`, `routes[].auth`, `auth.ask`, `auth.only_with_header`, `auth.accept`, `auth.send_request` | On `portable`, which sends `/public/` to `shop` with `auth = off` before its other prefix routes: a path under it reaches the service unchecked with a token the check denies, and so does one with a repeated slash, which the service hears merged; a client's own copy of the mark of a request the check could not answer does not reach the service there either. A path that `..`, `%2e%2e`, `..%2f`, `..%5C` or `..\` takes out of `/public/` leaves the route: with a token the check denies it gets the check's `401`, and with a token the check allows it reaches the service, and the check is told the path the service hears, the normalised one; without the normalisation each would stay on the route and reach the service unchecked. `..;` with a token the check denies leaves the route too and gets the check's `401`, and so does an empty segment before a `..`, `/products//../public/readme`, written or, over HTTP/2, escaped, which the `..` removes, where nginx answers `400`, a declared difference. A dot segment with a `;` parameter is answered `400` and reaches no service with no token and with a token the check allows, the `;` written after `%2e%2e` or escaped as `%3B` after `..`. On `full`, which has no such route, the first and the third are answered `401` by the check its shop route asks. A client's own user, question and unchecked mark do not reach the service on that route either, and a request to it logs no check time. Twenty-two rows, on `full`, `portable` and `nginx-auth`, and twenty-one on `haproxy-file`, which writes no `log`. | -| client keys | `routes[].rate_limit.by` | On `nginx-plain`, whose route `/limited/` admits one request a minute for each client under `client_address: forwarded`, eleven requests to that route, each after the rows before it, so a `200` is a client's first request and a `429` one whose bucket a row before spent: an `X-Forwarded-For` entry with a port, `10.80.0.1:80`, is the peer, so the next request with no entry is answered `429`; an address, `10.80.0.2`, is a client of its own, and the same address with spaces around it is the same client; an IPv6 address in capitals, `FD02::7`, is a client of its own, and `fd02:0::7`, the same address written another way, is the same client; the last entry of a list, `10.99.0.1, 10.80.0.3`, is the client, and that entry alone is the same client; an address in brackets, one with a leading zero and an IPv6 address with a zone are the peer, whose bucket is spent. On every other file that writes a limit's `by`, no route takes `/limited/`, so each request reaches `shop`. Eleven rows, on `full`, `portable`, `nginx-file`, `nginx-auth` and `nginx-plain`. | -| hash | `services..hash.header` | On `nginx-file`, whose service `sessions`, at shop's two addresses, picks a backend by the hash of `x-session-id` on the route `/sessions/`, which no rate limit holds: 20 requests with an empty `x-session-id` all reach one backend, an empty header being a value, and so do 20 whose header comes on two lines, `a` and `b`, and 20 whose two lines come as `c` then `d` and as `d` then `c` in turn, which reach different backends when the lines are hashed in the order they came. A value of `x`, 60,000 spaces and `y` is answered within 2 s, where nginx took about 14 s while its script trimmed the value with a regular expression; on `portable`, whose header size nginx reads in buffers of 49,120 bytes, nginx answers that line `400` itself, a declared difference. `full` and `portable` have no such route and send the path to `shop`, either backend. One value of the header sent 20 times reaches one backend every time on `nginx-file` and on `haproxy-traffic`, whose route `/sessions/` hashes it too. Five rows, on `full`, `portable`, `nginx-file` and `haproxy-traffic`. | -| tracing | `tracing`, `tracing.provider.otel`, `tracing.provider.otel.sample.rate`, `tracing.tags..header`, `tracing.tags..env`, `tracing.tags..default`, `tracing.path_in_url`, `auth.ask`, `auth.accept`, `routes[].rpc`, `origins..hosts` | On `nginx-tracing`, which traces 5% of the requests by their `x-request-id` and sends its spans to the battery's collector, each row sends an id the draw picks, `000001f3-...`, or one it does not pick, `000001f4-...`, and reads from the collector the span that carries its id, or finds none, beside what the service received: a request whose id the draw picks is traced, with a `traceparent` marked sampled, and one whose id it does not pick is not; an id that is not a UUID is drawn by its first eight characters, and one shorter than eight is never traced; a client's sampled `traceparent` continues the client's trace, its span the client's span's child, over HTTP/1.1 and HTTP/2, when the draw picks the id, and is sent on not sampled when it does not; one marked not sampled is never traced, and a malformed one reaches the service as sent, a byte 0xFF and each of two lines with its `tracestate` lines included, with no span, over HTTP/1.1 and to a gRPC service; a `traceparent` and a `tracestate` line after a tab are read as Envoy reads them; one of another version than 00 continues the client's trace and keeps the client's `tracestate`, and is sent on not sampled when the draw does not pick the id; two `tracestate` lines reach the service as one, a `tracestate` holding the byte 0xFF reaches the service and the check as sent, Envoy adds an empty `tracestate` when the client sends no `traceparent`, and a client's `tracestate` reaches the span; the check receives the trace, a parent of another version than 00 and one marked not sampled continued, and no trace beside a malformed `traceparent`; a span carries the Envoy output's fields, its `peer.address` is the connection's whatever `X-Forwarded-For` says, and over HTTP/2 its `http.protocol` says so; its `http.url` holds `http` or `https` alone from `X-Forwarded-Proto`, in any letter case, and the host_header of the route's service; a request no route takes and a path both proxies refuse are named `ingress`, and `%00` in the path, a fragment in the target, a refused upgrade and a request line of another scheme than http and https, which is answered `400`, are not traced; a target of 256 bytes is whole in the span, and a query after characters Envoy escapes, a dot-dot segment, a client's `x-envoy-original-path` and a route with a rewrite each give the span the Envoy output's URL; a header tag reads the first of two lines, and every line joined on a header Envoy joins, one sent empty is not set, one absent takes its default, a tag on a header the check accepts reads the value the check accepted, and its default on a route the check is off for, an environment tag whose variable is unset takes its default, and so does one on a variable named like a property every object has, one whose variable is set reads it, and one on a set variable named like such a property reads it through the Envoy output and takes its default through nginx, a value keeps a quote, a backslash and bytes above 0x7F, and a default keeps a dollar, a quote and a backslash; a tag named like a span field replaces it, and keeps the field's value when its header is absent; the tracing headers a client sends do not reach the service; a gRPC call's service receives the span's `traceparent`; a User-Agent after a tab is held by the span without it; a request from a refused origin is traced under its route. nginx's own literals are the differences its rows of `tracing.provider.otel`, `tracing.path_in_url` and `tracing.tags..header` declare: a `traceparent` of another version than 00, or after a tab, is sent on to the service and the check with the client's version and ids and no span, and a `tracestate` after a tab beside a parent gives no span, a User-Agent after a tab gives no span and is sent on not sampled, a gRPC call's malformed `traceparent` on two lines is answered `400`, a target the Envoy output normalises or rewrites, or beside a client's `x-envoy-original-path`, gets no span and is sent on not sampled, and the query after characters Envoy escapes is answered `400` on `nginx-tracing`, whose path nginx refuses, no empty `tracestate` goes with a `traceparent` of nginx's own, the status in a span is a number, a request no route takes has an empty `upstream_cluster`, a refused origin's span is named `ingress`, a target over 256 bytes gets no span, and an empty or absent header tag is set empty. On `full`, which traces 10% with `client_address: connection` to a collector its world leaves unreachable, a row reads what the service received, and nothing the draw decides. | -| tracing a retried request | `tracing`, `routes[].retries` | With `shop-2` refusing connections, 40 traced requests to the retried route `/retried/` are each answered by `shop-1` and have one span, named `retried`, with `upstream_cluster` `shop_http` and the status `200`, whose trace and span ids are those of the `traceparent` the service read on the try that served it. | -| rate limit | `routes[].rate_limit`, `routes[].rate_limit.requests`, `routes[].rate_limit.per`, `routes[].rate_limit.burst`, `routes[].rate_limit.by`, `auth.ask` | After 2.5 s with no request to the route, 60 requests to `/catalog/items` back to back: the first 30 on `full`, `nginx-file` and `nginx-auth` (20 a second and a burst of 10) and the first 20 on `portable` (20 a second and no burst) answer `200`, and at least one of the rest `429`; then, of 60 requests over the limit that carry a token the check denies and one the token filter refuses, at least one is answered `429`, not `401`, so the limit is applied before the token and the check; of 60 `POST`s over the limit with a body of 5 bytes, at least one is answered `429`, and of 60 more with the next request written after the body, at least one ends its connection, so that next request gets no answer (each row after the first sends 60, as a row of 10 that finds the bucket full, which the row before may leave it, gets no `429`); of 60 gRPC calls over HTTP/1.1, told by their content type, with a body and the next request written after it, at least one ends its connection too; of 60 gRPC calls over HTTP/2, at least one is answered `200` with `grpc-status` `8` and `content-type: application/grpc`, and of 60 Connect calls, `POST`s that carry `connect-protocol-version`, at least one `429` with `content-type: application/json`; another route is not limited; and after 2 s with no request to the route, of 40 requests the check denies, the first 30, or 20 on `portable`, are answered `401` and at least one of the rest `429`, so a request the check denies spends a token. On `nginx-file`'s route `/retried-limited/`, which admits 10 requests a minute for all and retries once, with one shop backend refusing connections, the first 10 of 40 requests are answered `200` and at least one of the rest `429`, so a request whose first try was refused spends one token, not two and not none; `full`, `nginx-auth` and `nginx-plain` serve the path by their shop routes, so there at least one answer comes from the backend that is up. Ten rows: all on `full` and `nginx-auth`, nine on `portable`, which writes no retries, eight on `nginx-file` and `haproxy-traffic`, which write no check, and two on `nginx-plain`, whose route `/limited/` has no burst: another route is not limited, and the row of a limited route whose first connections were refused, which its shop route serves. | -| cost | `routes[].pattern`, `routes[].prefix`, `origins..patterns`, `limits.request_headers.size` | A path of 14,000 bytes that 24 pattern routes read, sent with an origin a pattern covers, reaches the prefix route's service with `access-control-allow-origin` within 500 ms, and an `Origin` of 8,000 bytes that 64 patterns of two `*` read is answered `403` within 500 ms; the request after each is served, which only a proxy still running answers. Each stopped HAProxy before its patterns ran in steps and its origin patterns were written so they cannot backtrack ([HAProxy](haproxy.md#what-a-pattern-route-costs)). On `nginx-file` the long path is served as on the other files, nginx's header buffers reading a request line as long as the header limit ([nginx](nginx.md#the-header-limits)), and so is a path of 61,000 bytes, about the longest nginx reads at the file's 60 KiB, a head of 61,133 bytes under the 61,376 it reads ("a path of 61,000 bytes, about the longest nginx reads at 60 KiB, that 24 pattern routes read"): every file but `haproxy-file` serves it with `access-control-allow-origin` within 500 ms, and HAProxy answers `414`, a declared difference; an `Origin` of 6,420 bytes that the last of the 64 patterns takes reaches the service with `access-control-allow-origin`, where HAProxy answers `403` before the service, as it answers any admitted `Origin` longer than it echoes, a declared difference, and one of 6,321 bytes that the 64 read is answered `403`, each within 500 ms on `haproxy-file` and `nginx-file`, the files that name an environment with its host, rows of their own because nginx's first form of the patterns refused the first and held a worker past the bound with the second ([nginx](nginx.md#what-a-pattern-route-and-an-origin-pattern-cost)). Two more `Origin`s sit past the bound nginx sets on the origin patterns. One of 16,384 bytes that the last of the 64 patterns takes ("an Origin of 16,384 bytes that the last of 64 patterns of two * takes") and one of 16,385 bytes ("an Origin of 16,385 bytes that the last of 64 patterns of two * takes") are served and echoed within 500 ms by Envoy and answered `403` within 500 ms by nginx, which matches no `Origin` longer than 8,192 bytes against the patterns, a declared difference on `origins..patterns`; HAProxy answers both `431`, as it answers any head that outgrows its buffer, a declared difference. A path of 53,005 bytes that the 24 pattern routes read, with an `Origin` of 8,192 bytes that the last pattern takes, the longest nginx matches, in a head of 61,326 bytes ("a path of 53,005 bytes and an Origin of 8,192 bytes that the last of 64 patterns of two * takes, about the longest head nginx reads at 60 KiB"), is served with the `Origin` echoed within 500 ms on `nginx-file` and `nginx-auth`, the files that write `limits.request_headers.size` and name the `Origin`'s host, and answered `404` on `full` and `portable`. On `full` and `portable`, which name no environment with the long `Origin`'s host, each long `Origin` is answered `404`. Then 3,000 requests over 24 connections at once, each to a path of `/k01/` to `/k40/` and 1,000 random `a` and `b`, which 40 pattern routes of `haproxy-file` read, are each served by the prefix route's service, and the proxy's memory, read through Docker's API, grows by less than 96 MiB and 4 MiB for each CPU Docker gives a container, 144 MiB with 12: HAProxy runs a thread for each CPU, and each keeps the states of its own patterns, where Envoy's RE2 keeps a cache for each pattern. On `haproxy-file` with 12 CPUs, HAProxy grew past the bound on the code before the states of a thread shared one budget and with a budget of about 8 MB a thread, and stays under it with the script's, of about 1 MB. It runs on every file that writes pattern and prefix routes, which `haproxy-file`, `nginx-file` and `nginx-auth`, the files with the 40 routes, share with `full` and `portable`. The row logs the memory it read on every run. Last, 2,000 connections are opened as a raw request's would be, over TLS with the client certificate on the files that write `tls`, and each sends the 65 bytes `GET /products/1 HTTP/1.1`, a line break, `Host: localhost`, a line break, `x-pad: ` and 15 `a`, one more than nginx's first header buffer of 64 bytes, and then nothing ("connections each holding a head just over 64 bytes keep the proxy's memory bounded", on `full`, `portable`, `nginx-file` and `nginx-auth`, the files that write `limits.request_headers.size`). The proxy's memory, read through Docker's API before the first connection opens and 3 s after the last, must grow by less than 64 KiB for each connection, 125 MiB for the 2,000, and every connection must still be open with no answer right after. In the eighteen runs whose times are given below, Envoy grew by 27.4 to 33.5 KiB a connection, median 30.6 KiB, and nginx 1.30.6 and 1.31.8 by 23.3 to 26.5 KiB, median 24.7 KiB, on `nginx-auth`, 27.1 to 30.7 KiB, median 28.8 KiB, on `nginx-file` and 48.5 to 52.1 KiB, median 51.2 KiB, on `portable`. One header buffer of 8 MiB in place of nginx's buffers fails the row with 2,000 connections and passes it with 500, so the row keeps 2,000. The row catches that one large buffer only where the kernel's transparent huge pages are `always`, as Docker Desktop's are, because the buffer then takes a whole huge page of 2 MiB; with `madvise` or `never` such a buffer costs the pages a head touches and can pass the row. On every kernel the row bounds the memory a connection holds, and the generator's own test holds the buffers' form. The row logs the memory it read. Every one runs on `nginx-file` and `nginx-auth`. | -| connection limit and failed backends | `limits.connections`, `services..health` | On `nginx-limits`, whose limit is two, three requests sent at once on one HTTP/2 connection, each held 1 s by the service: nginx's own `limit_conn` serves two and answers the third `503`, a declared difference, and the Envoy output serves all three. On `full`, whose limit is 4096, all three are served. Then four requests while `shop-2` refuses connections, at least one served, and six right after it takes them again, each served by `shop`: on nginx, whose passive check took `shop-2` out for 10 s, each by `shop-1`, a declared difference. On `haproxy-limits`, whose shop service has one address, HAProxy's own `maxconn` serves two and holds the third in its queue until one ends, so it is answered a second after the others, a declared difference. Three rows, on `full` and `nginx-limits`, and the first on `haproxy-limits`. | -| traffic keys | `limits.request_headers.size`, `limits.request_headers.count`, `services..health`, `log` | A header block of 50 KiB reaches the service and one of 200 KiB is refused, and 120 header lines reach it and 200 are refused; the files of nginx's battery hold 100 lines, so they refuse 120, and on `portable`, whose 96 KiB nginx reads in buffers of 49,120 bytes, nginx answers the 50 KiB line `400`, a declared difference. With `shop-2` refusing connections, every one of 20 requests to `checked`, checked every second, reaches `shop-1` once 3 s have passed; on `full` the shop route's retry gives the same answers. A request whose service answers `404` is logged; HAProxy's line, of its own `log-format`, holds no path, so the row finds it by its frontend, backend, status, method, version and quoted request id, a declared difference. Six rows on `full` and `haproxy-traffic`, and five, all but the health row, on `portable`, `nginx-file`, `nginx-auth` and `nginx-tracing`. | +| routing | `routes[].pattern`, `routes[].path`, `routes[].method`, `routes[].rewrite`, `routes[].prefix`, `routes[].to`, `services..http`, `services..addresses`, `services..address`, `services..host_header`, `dns.resolver`, `origins..hosts`, `client_address`, `tls.certificate`, `limits.request_headers.count`, `limits.request_headers.size` | A pattern route, and a path its pattern misses going to the prefix route; a path and method route with its rewrite, and another method going to the prefix route; a service whose address the resolver gives; the prefix route over HTTP/1.1 and over HTTP/2, where the service still hears HTTP/1.1; the host each service hears, `host_header`'s value for `accounts`; a host of another environment; `404` for a host no environment names, with no `content-type`, with `vary: Origin` and with an `x-request-id` the proxy makes; a service at its one address; a path compared by letter case, `/API/webhooks` going to the prefix route; the path `/_pf_auth`, written and with its underscore escaped, routed as any other; an escaped newline, `%0A`, at the end of a path and inside one, matched by the patterns as written and passed on as sent; an upgrade other than WebSocket answered `403`, and an `h2c` upgrade served as a plain request whose service receives no `upgrade` or `http2-settings`, which HAProxy answers `400`, a declared difference; the scheme the request came in on, in `x-forwarded-proto`; with `client_address = connection`, a client's own `x-forwarded-proto` replaced by the connection's scheme, and its own `x-envoy-external-address` and `x-request-id` by values the proxy writes; each of 32 requests that carry no `x-request-id` gets one the proxy makes, a version 4 UUID in lower case, 8-4-4-4-12 hexadecimal digits with the third group starting with `4` and the fourth with `8`, `9`, `a` or `b`, and the answer carries it too; `502` with no `content-type` for a service that refuses connections, and `502` with no body for a service that takes no connection within 5 s ("a service that takes no connection within 5 s is answered 502"), which only `nginx-plain` has, as its `hold` service behind the route `/hold/` ([The world](#the-world)): Envoy and nginx answer it after at least 4.95 s and under 5.95 s, the connect time of both with no `timeouts`, and every other file serves `/hold/x` from `shop`; a service's `X-Accel-Redirect` passed on to the client, not followed; a service's `Keep-Alive` not passed on to the client; the headers the Envoy output removes (`proxy-connection`, `x-forwarded-client-cert` and the `x-envoy-` headers that steer an Envoy) never reach the service; the host of an absolute request line, not the `Host` header, is the host the service hears, where HAProxy answers every absolute target `400`, a declared difference; an `Upgrade` that `Connection` does not name is removed and the request served; header names holding `_` or `.` reach the service; `TE: gzip, trailers` reaches it as `trailers`; `404` for a host with a dot at its end, with no `content-type`, as the `404` of an empty `X-Forwarded-Proto` and the `403` of an upgrade other than WebSocket from no origin; `400` for a method Envoy's parser does not know, with no `x-request-id`, and after the `400` of a byte above 0x7F in the target, of a header name holding `@` and of `HTTP/1.10` the connection closed, so a request written after it gets no answer, and after the `426` of `HTTP/1.9` and the `403` of an upgrade other than WebSocket, from no origin or a foreign one, closed too, where HAProxy keeps it and serves the request after the body, a declared difference; a `QUERY` with a `Content-Type` served and one with none answered `400`, over HTTP/1.1 and HTTP/2, the `400` with no `content-type` and no `x-request-id`, before the `404` of a host no environment names too; a `QUERY` whose `Content-Type` is spaces alone answered `400` over HTTP/1.1 and served over HTTP/2, where HAProxy answers it `400` over HTTP/2, a declared difference, and one whose `Content-Type` is a tab answered `400` over HTTP/1.1; a pattern's `{,3}` read as text, as RE2 reads it; a long path `((a\|a)*c\|a+b)` takes, which PCRE2 gives up on with the pattern as written, reaching its route; and a long path that makes PCRE2 give up on `(a\|aa)+`, which goes on to the prefix route on Envoy and is answered `400` by nginx, a declared difference. A header name outside RFC 9110's token characters, `x@at`, `x(p)` or one holding the byte 0xFF, is answered `400` over HTTP/1.1 and refused over HTTP/2, where Envoy closes the connection and nginx answers `400`, a declared difference; the same requests, written by hand, with a name of token characters reach the service, and `x-ok`, `x_und` and `x.dot` reach it over both. A header value holding a control byte other than a tab is answered `400` over HTTP/1.1 and refused over HTTP/2, where Envoy closes the connection, HAProxy resets the stream and nginx answers `400`; a value holding a tab and UTF-8 reaches the service over both. A client that sends its request and closes its side of the connection before the service answers gets no answer: Envoy closes the connection, and HAProxy answers `400` or `403` or closes it. The row has its service hold its answer for 500 ms (`x-stub-delay`), because a proxy that reads the client's close after the service's answer passes the answer on: with a service that answered at once, a close sent with the request got no answer in 300 of 300 tries through Envoy and each nginx, and one sent 1 ms later got the service's `200` in 297 of 300 through Envoy and 300 of 300 through each nginx, so the row was a race, and it failed once in a whole run on nginx 1.31.8 and once on HAProxy 3.4.7. Under `client_address = forwarded`, an empty `X-Forwarded-Proto` from a client in front is answered `404` ("an empty X-Forwarded-Proto from a client in front is answered 404"), and with `connection` the request is served with the connection's scheme in its place; an `X-Forwarded-Proto` of spaces alone over HTTP/2 is served, where HAProxy answers `404`, a declared difference. A header written `x_forwarded_proto`, a name nginx reads as its own `X-Forwarded-Proto`, reaches the service as sent through Envoy and is answered `400` by nginx, a declared difference; `x_forwarded_for`, which nginx does not read as its own `X-Forwarded-For`, and a header named `constructor` or `__proto__`, over HTTP/1.1 and HTTP/2, reach the service as sent through both. Two `Accept` lines reach the service as one line through Envoy and as two lines through nginx, the same message, and two `Content-Type`, `User-Agent`, `Referer` or `If-Match` lines are joined and served by Envoy and answered `400` by nginx, each a declared difference on nginx's request-line row. With two or three spaces around an absolute target, the target's host is the host the service hears whatever the `Host` header says, and one that ends with a dot gets `404`; a tab after the method is served by Envoy and answered `400` by nginx, a declared difference; an absolute target whose host a query follows is refused. `TE: Trailers` reaches the service as `trailers` when `Connection` names `te` and is removed when it does not, and `Connection: close,` is served. An absolute target with an empty port, `http://localhost:/products/1`, is answered `400`. A chunked body's trailer reaches the service through no proxy, which receives the body; a trailer whose name holds `@` is answered `400` by Envoy and let through by nginx, which serves the body without it, and so is a trailer whose value holds a control byte, which HAProxy lets through too, over HTTP/1.1 and HTTP/2, and over HTTP/2 a trailer is served by Envoy and ends the connection on nginx, each a declared difference. A header line with no colon is answered `400` by Envoy and reaches the service through nginx as a header with an empty value, one of nginx's less strict ways. A header line folded onto the next, with a space or a tab, is served by Envoy and answered `400` by nginx and HAProxy, and a `Host` whose port is `99999` or `+1` is served by Envoy and answered `400` by nginx, declared differences. 100 header lines reach the service and 101 are refused (on `full` and `portable`, whose `limits.request_headers` admits 150, they reach it), and 96 header fields over HTTP/2 reach it, which nginx refuses, one field under Envoy's count, a declared difference, and 97 are refused ("97 header fields over HTTP 2 are refused", on the files that write `limits.request_headers.count`: Envoy resets the stream and nginx refuses the request, and `full` and `portable`, whose count is 150, serve them), and so are 96 beside `:authority` and a `host` field of the same value, which Envoy counts as two fields ("96 header fields over HTTP 2 beside :authority and a host field are refused", on the same files); HTTP/1.0 is answered `426`, with no `x-request-id`, and so are `HTTP/1.2`, `HTTP/1.9`, `HTTP/0.9` with headers, where nginx answers `400`, and `HTTP/2.0` on an HTTP/1 connection, where nginx answers `505`, and a request line with no version, where HAProxy answers `400` and nginx closes the connection, each a declared difference; `HTTP/1.10` and `HTTP/1.01` are answered `400`, and a method in lower case `400`; a header a `Connection` token names does not reach the service, where nginx and HAProxy answer `400`, a declared difference, and neither does `Keep-Alive`; `HTTP2-Settings` on a request that is no upgrade reaches the service; ten `Connection` tokens are answered `400` and nine served, a token and ten empty elements are served, where HAProxy answers `400`, a token and nine elements of white space are answered `400`, and ten tokens `close` are answered `400`, where HAProxy serves them, each a declared difference; a WebSocket over HTTP/2 is refused; over HTTP/2 an `:authority` with an empty port, `localhost:`, reaches the service as sent, where HAProxy sends `localhost`; two `Host` lines of one host are answered `404`, where HAProxy serves the request and nginx answers `400`; two `Content-Length` lines of one value, and `Content-Length` beside `Transfer-Encoding: chunked`, are answered `400`, and `Transfer-Encoding: gzip, chunked` `501`, where HAProxy serves the first two and answers the third `422`; a `POST` with no body reaches the service with `content-length: 0`, which neither nginx nor HAProxy sends; a WebSocket upgrade the service answers `200` without switching reaches the client with no body, where nginx and HAProxy pass the service's; a header of 20,000 bytes and a path of 20,000 bytes reach the service, where HAProxy answers `431` and `414`; on the files that write `limits.request_headers.size`, a head 64 bytes under the size, 61,376 bytes for the 60 KiB `nginx-file` writes, reaches the service as a header block ("a header block 64 bytes under the size", one header of 61,322 bytes) and as a request line ("a request line 64 bytes under the size", a path of `/products/` and 61,332 `a`), and a head one byte over Envoy's bound, 61,441 bytes, is refused: Envoy answers `431` to both, and nginx `400` to the header block ("a header block one byte over the size") and `414` to the request line ("a request line one byte over the size"), its own literal under `limits.request_headers.size`, while `full` and `portable` write 96 KiB and serve both; nginx reads a head of 61,376 bytes at most ([nginx](nginx.md#the-header-limits)), so the rows 64 bytes under have no margin on it; and over HTTP/2 a path of 7,000 bytes above 0x7F reaches the service, which HAProxy refuses and nginx answers `400` on `nginx-file`, each a declared difference; and a service that closes the connection of the first request a client sends on its connection before it answers is answered `502`, and so is one that closes, before its answer, a connection to `catalog` the proxy kept from a request on the client's same connection, over HTTP/1.1 and HTTP/2, the request reaching it once, where HAProxy sent it again before each request had a connection of its own. On `haproxy-file`, whose `test` environment has the hosts `.dot.example.com`, `dot.example.com.`, `-f`, `-i` and `-n`, a request to each reaches the service with that host, and on every other file it gets `404`. With `client_address = connection`, a client's `X-Forwarded-For` reaches the service on one line with the peer's address, and so do two lines of it, which Envoy joins, where nginx answers `400`, a declared difference, and the `x-envoy-` headers only a proxy in front may send (`x-envoy-decorator-operation`, `x-envoy-downstream-service-cluster`, `x-envoy-downstream-service-node`, `x-envoy-original-host`, `x-envoy-original-path`) do not reach it. The check location's own path, `/.proxyfile/check`, written or with its dot escaped, is routed as any other path and reaches `shop` as written, a prefix route's path without its slash, `/catalog`, is routed and not redirected, and a client that closes its side of the connection right after a request with a dot segment with a `;` parameter gets no answer, where nginx answers `400`, a declared difference. In Envoy's entry: 150 rows on `full`, `portable` and `nginx-file`, 149 on `nginx-auth`, which writes no `dns.resolver`, 144 on `haproxy-file`, which writes no `limits.request_headers`, 144 on `nginx-tracing`, which writes no `dns.resolver`, no `tls` and no `client_address`, and 131 on `nginx-plain`, `two-checks` and `nginx-checks`, which write none of those, no `limits.request_headers` and no pattern route. | +| mutual TLS | `tls.certificate`, `tls.key`, `tls.clients.ca`, `origins..hosts` | A client with no certificate, one whose certificate another CA signed, and one whose certificate the clients CA signed and whose validity ended reach no service: the handshake fails, or the proxy refuses it, where nginx completes the handshake and answers an empty `400`, the difference nginx's row of `tls.clients.ca` names. A request whose TLS server name is one host of an environment and whose `Host` is another host of the same environment is served by Envoy and answered with an empty `421` by nginx, which asks for client certificates, a declared difference. The other CA carries the clients CA's name, so a proxy that matched the issuer by name would let it through. Every other row sends a client certificate the clients CA signed. A client that offers only TLS 1.1, a TLS 1.2 client that offers only a CBC suite, and one that offers only the group P-384 are refused in the handshake, and one that offers only the group X25519MLKEM768 is served. Plain HTTP sent to the TLS port, with a token the check allows, reaches no service: the Envoy output and HAProxy close the connection, and nginx answers an empty `400`, the difference nginx's row of `tls` names. In Envoy's entry: 9 rows on `full`, `portable`, `nginx-file`, `haproxy-file` and `nginx-auth`, the files that write `tls`. | +| CORS | `cors.allow_methods`, `cors.allow_headers`, `cors.expose_headers`, `cors.max_age`, `origins..hosts`, `origins..origins`, `origins..patterns` | A preflight from a listed origin and one from an origin a pattern covers answer `200` with `access-control-allow-origin` and `access-control-max-age`; a preflight and a request from another origin answer `403`, and so does a request from another origin to a path ending `.html`, as `text/plain` on every proxy, whose own answers take no type from the path's ending; a request from a listed origin reaches the service with its `origin` and is answered with `access-control-allow-origin` and `access-control-expose-headers`. The preflight from a listed origin and the request from another origin carry a token the check denies and one the token filter refuses, each answered `401` alone, so on a file that writes the check their `200` and `403` show that the origin is decided before the token and the check. An origin on the environment's own host that neither list holds, `https://api.example.org` to `api.example.org`, is admitted without `access-control-allow-origin`: its request reaches the service and its preflight answers `200`. With no list, an origin on one of the environment's hosts is admitted and every other refused: a request with no `Origin`, and one from `http://localhost` over `http` or `https`, with a port, or from the environment's other host `http://127.0.0.1` reaches the service, and a preflight from `http://localhost` is answered `200` by the proxy; an origin on another environment's host, the host in capitals, with a trailing dot or with other characters for its dots, `null`, a present but empty `Origin`, a preflight from another origin and a WebSocket upgrade from one answer `403`, where HAProxy's parser answers that upgrade, which carries no `Sec-WebSocket-Key`, `400`, a declared difference. An empty `Origin` over HTTP/2 is answered `403` too, and an empty `Origin` line before or after the origin of the host, or a tab before that origin, changes nothing: the service receives the origin as one line. A preflight from a listed origin with no token is answered with the method and the headers it asks for; one from a listed origin in capitals is admitted with the origin as sent, and one from a pattern's origin in capitals is refused. The `Origin` header is read as one line: two `Origin` lines a pattern covers when joined are admitted with the joined line in `access-control-allow-origin`, where nginx answers `403`, a declared difference, two whose first is listed, two of the request's own origin, and one line holding a listed origin after a comma are refused, and an empty `Origin` line after a listed one is left out; a preflight that asks on two lines for two methods or for headers is answered with both, joined with a comma, and by nginx with a comma and a space, a declared difference. A listed origin with a trailing space is admitted, and the service receives it without the space. A service that is down, asked from a listed origin, is answered `502` with `access-control-allow-origin` and `access-control-expose-headers`, and a request from a listed origin to a host no environment names is answered `404` with no `access-control-allow-origin`. A refused path, a preflight to it, an upgrade other than WebSocket, a request with a NUL byte in a header from a listed origin and one with `Content-Length` beside `Transfer-Encoding: chunked` from it are answered with no `access-control-allow-origin`, where HAProxy serves the last with it, a declared difference, and a header line of 9,000 bytes from one is served with it by every proxy, nginx's header buffers reading a line as long as the header limit ([nginx](nginx.md#the-header-limits)). An admitted `Origin` of 600 bytes is echoed beside a service's answer of 100 KB, and so is one of 1,100 bytes, where HAProxy answers `403` before the service, a declared difference. A preflight from a listed origin to `/..;x/products/1`, with no token and with a token the check allows, is answered `200` by Envoy, which resolves the path and asks no check, and `400` by nginx and HAProxy, which with the token ask the check first, each a declared difference, and a denial of the check from a listed origin carries `access-control-allow-origin` and `access-control-expose-headers`. In Envoy's entry: 52 rows on `full`, `portable`, `haproxy-file`, `nginx-auth` and `nginx-tracing`, 50 on `nginx-file`, which writes no check, and 19 on `nginx-plain`, `two-checks` and `nginx-checks`, which write no list of origins and no `cors`. | +| auth | `auth.ask`, `auth.only_with_header`, `auth.send`, `auth.accept`, `auth.send_request`, `auth.timeout`, `auth.when_unavailable`, `routes[].auth`, `remove_from_clients`, `auth.jwt.claims`, `services..host_header`, `cors.expose_headers`, `origins..origins`, `log` | A request with no `authorization` header reaches the service, which it could not if the check were asked; when the check allows, the service receives the check's headers `auth.accept` admits and not another, and what the check was told (the method, the path with its query, `x-country`), never the `x-forwarded-uri` and `x-forwarded-method` the client sent; the check's `401` and `403` reach the client, without the `x-envoy-upstream-service-time` Envoy's client for the check adds; a check that answers `503` lets the request through, as `when_unavailable = allow` says, and on `two-checks` and `nginx-checks`, whose `when_unavailable` is `deny`, gets `403`; the mark of a request the check could not answer reaches the service, and a client's own copy never does, whether the check allows or is not asked; a route with `auth = off` is not checked; a client's own copies of the headers `remove_from_clients` names, of the check's headers and question, and of the headers `auth.jwt.claims` sets never reach the service. A header `remove_from_clients` names does not reach the service when a client sends it on two lines, one with its name in capitals; a client's own `x-request-id` is replaced by another when `remove_from_clients` names it; and on `two-checks`, whose `remove_from_clients` names the prefix `ho*`, a client's `ho-x` does not reach the service and its `Host` does. The check is told it is internal and its deadline, `x-envoy-internal: true` and `x-envoy-expected-rq-timeout-ms: 1500`; a header sent on two lines reaches it as one line, joined with a comma; a client's own `x-forwarded-proto` reaches it under `forwarded`, and the connection's scheme under `connection`; it receives the `Host` the client sent whatever the check service's `host_header`; and the `only_with_header` header sent twice, an empty line before or after the token, asks it. A check's `201` is answered `403`, and a status of `600` is passed on as the check's own, where HAProxy and nginx answer `403`. A denial of 20,000 bytes, and one with a header of 50,000, reach the client, and an allowing answer whose `x-user-id` holds 20,000 bytes sets it on the request where `auth.accept` admits it, where HAProxy answers each `403`, a declared difference. An answer whose body breaks off, and one of 101 header lines, are a check that could not answer: the request is served with the mark under `allow` and answered `403` under `deny`. A `200` that RFC 9112 does not read whole is such a check for Envoy too, in these forms: a `Content-Length` that is not a number, two `Content-Length` lines, a control byte in a header value, a status that is not three digits, a header name outside the token characters, `Content-Length` beside `Transfer-Encoding`, a chunk size that is not hexadecimal, a malformed header line in a `1xx` before it, and a malformed trailer line; HAProxy answers each `403` under `allow` too, a declared difference. Of 24 requests while `check-2`, one of the two check backends of `two-checks` and `nginx-checks`, refuses connections, at least one is answered `403` on those files: no other backend answers a check it refused. Rows for each form of an answer a check can write that RFC 9112 reads in a way of its own hold Envoy's reading, measured on Envoy 1.40.2: a status line of `2 0 0`, `20` or `000`, of `304` or of `101` is passed on as the check's own, and so is a denial with a folded header line; a status of `200.1`, `500`, `599`, or `503` with a body, a `200` with a header line with no colon, a header value with a vertical tab, `Transfer-Encoding: gzip, chunked`, or `identity` beside a `Content-Length`, a chunk that does not end its line, a space before a header's colon, a header name that holds a NUL or the byte `0xE9`, and a `Content-Length` past what any reader holds, are each a check that could not answer, and so is a denial with a header line with no colon; a `200` of `HTTP/2.0`, with two spaces after its version, with a space after a chunk's size, with spaces around its `Content-Length`, with a lone CR before a CRLF, with `_` in a header name, with bytes after its body, with a body of 1 MiB, or holding the relay's own header name `x-proxyfile-check`, is read as allowed. A denial with a body of 1 MiB, of 1 MiB and a byte and of 1,100,000 bytes reaches the client whole, and a denial's header that holds the byte `0xE9` reaches it as the check wrote it, and a denial with no body reaches it with no `content-type`. A `200` whose chunk-size line ends in a bare LF, or whose last chunk's line does, is a check that could not answer on Envoy, and a `200` whose chunk data, trailer line and final line end in a bare LF is read as allowed; nginx's relay and HAProxy's script refuse the first two under `allow` too, a declared difference. A `200` whose accepted header is folded reaches the service with the spaces and tabs of the fold, a tab, spaces on both lines or two folds, where HAProxy joins them by one space, a declared difference, and one whose accepted header is empty reaches the service empty. A `200` whose accepted header takes the request past the header size is answered `500`, where HAProxy answers `431`, a declared difference, and one whose accepted headers take it past the header count, 100 fields as Envoy counts them, is answered `500` by Envoy on every file but `full` and `portable`, which serve it, by nginx and by HAProxy, with an admitted origin's CORS answer, where one they take to the count is served: with `client_address: connection` the `x-forwarded-for` and `x-envoy-external-address` the proxy sets count too, so 87 lines from the client reach the count there and 91 elsewhere. A `200` that sets no accepted header is not counted, so with 96 numbered lines beside it the request is served by every proxy. With the accepted header and 91 numbered lines, a request with a chunked body is served, its `Transfer-Encoding` line not counted, and one with a body framed by its length is answered `500`, its `Content-Length` line counted, on `two-checks` and `nginx-checks`, where `haproxy-file` and `nginx-auth`, with three accepted headers and the two the proxy sets under `client_address: connection`, answer both `500` and `full` and `portable`, whose count is 150, serve both; and a gRPC call over HTTP/2 whose accepted header and 87 numbered fields take it past the count is answered `200` with `grpc-status` `2` and reaches no service, and one with 86 is served, where `haproxy-file` and `nginx-auth` answer 86 with `grpc-status` `2` too and `full` and `portable` serve both. nginx's relay reads some of these forms otherwise, and each such row holds nginx's own answer under `by`, named by the row of `auth.ask` or of `auth.when_unavailable` that declares it. Rows for how nginx asks the check hold Envoy's answer, and nginx's own where it declares a difference: the check location's own path asks the check as any other path does; an upload sent with `Expect: 100-continue` that the check refuses gets `100 Continue` first; a request with a body the check allows reaches the service with its body; a sent header that holds the byte `0xE9` reaches the check with a `!` for it, one that holds well-formed UTF-8 reaches it as sent, one that holds well-formed UTF-8 and then a byte that is not reaches it with a `!` for that byte, a header on two lines of characters outside ASCII reaches it as sent, joined by a comma, and a path of well-formed UTF-8 and then a byte that is not, over HTTP/2, is told to it escaped, as the service receives it; an `only_with_header` header sent as a lone tab is not asked; 100 checked streams at once on one HTTP/2 connection are each answered by their own check; an absolute target's host is the host the check is told, whatever the `Host` header, and its scheme under `forwarded`, where under `connection` the check and the service are told the connection's; a client's own user, question and unchecked mark do not reach the service when the check allows with none of them, and the check receives none of a client's own removed header, user and mark; a dot segment with a `;` parameter asks the check first, and is answered `400` when the check allows; a denial of a request from a listed origin carries the CORS answer; a WebSocket upgrade the check allows reaches the service, and one it denies is answered with the denial; a header the check's answer sets on one request is not on the next request of the same connection, and a check's `2xx` other than `200` is answered at once on a kept-alive connection; a request the check denies, one whose check is unanswered and one whose check's status is passed on each have a body that holds a request read as a body, and the next request on the connection is answered, where nginx and HAProxy answer a status of `600` `403` and the unanswered one is `403` first on `two-checks` and `nginx-checks`; a client's own `x-proxyfile-method` and `x-proxyfile-path` change nothing the check is told; the check is told the path with an escaped letter, with a dot-dot segment and a query, with a query's escapes of unreserved and of reserved characters, and with a quote; an HTTP/2 request is told its `:scheme` under `forwarded`, and under `connection` the check and the service are told the connection's scheme; a client's `HTTP2-Settings` of an h2c upgrade does not reach the check, and with no upgrade it reaches it when `send` covers it; a check's redirect whose `Location` is a path reaches the client as the check sent it; and the request log holds how long a denied request's check took, no check time for a request with no `only_with_header` header, and an unanswered check for a request the check cannot answer under `allow`. A request to a retried route is checked once, before its first try: with one shop backend refusing connections, each of 20 requests the check allows reaches the other backend with the header the check accepted, each of 6 it denies is answered `403` with no service, and each of 10 whose check answers `503` reaches the other backend with the unchecked mark under `allow` and is answered `403` under `deny`. In Envoy's entry: 152 rows on `full`, 151 on `nginx-auth`, which writes no `auth.jwt.claims`, 148 on `portable`, which writes neither that nor `routes[].retries`, 148 on `nginx-tracing`, which writes no `auth.jwt.claims` and no `client_address`, 144 on `haproxy-file`, which writes neither of the first two, no `log` and no `limits.request_headers`, 132 on `nginx-checks`, which writes none of `auth.jwt.claims`, `auth.send`, `log` and `client_address`, no `limits.request_headers`, no route with `auth = off` and no list of origins, 129 on `two-checks`, which writes no `routes[].retries` either, and 3 on `nginx-file` and `nginx-plain`, the rows of `remove_from_clients`, which they write with no check. | +| the scheme the check is told | `client_address`, `auth.ask`, `auth.accept`, `auth.send_request` | Each row asks the check, which reports the scheme it was told, and the service reports the `x-forwarded-proto` it received. Under `client_address: connection` every proxy tells the check and the service the connection's scheme, whatever the client writes: an absolute `https` target, and one written `HTTPS://`, is served over TLS and told `https`, but by HAProxy, which answers an absolute target `400`, and on `connection`, over plain HTTP, the Envoy output answers it `403`, and nginx serves it and tells the check and the service `http`, a declared difference; the same request with a token the check denies is answered `401` where the check is asked, and `403` by the Envoy output on `connection` and `400` by HAProxy on every file, so neither asks the check; an absolute `http` target with that token is answered `401`, and `400` by HAProxy; an HTTP/2 request with `:scheme https`, or with `:scheme ftp`, is told `https` over TLS and `http` on `connection`; and a client's own `x-forwarded-proto` of `https`, `http` or `ftp` is replaced by the connection's scheme. Under `forwarded`, on `two-checks`, `nginx-checks` and `nginx-tracing`: an absolute `https` target sent with `x-forwarded-proto: http` is told `https`, the target's scheme, and the service is sent `http`, where HAProxy answers `400`; an HTTP/2 request with `:scheme https` sent with `x-forwarded-proto: http` is told `https` by the Envoy output and `http` by nginx and HAProxy, a declared difference, and the service is sent `http`; and an `x-forwarded-proto` of `ftp` reaches the service as sent, while the Envoy output tells the check `http`, the connection's scheme, and nginx and HAProxy tell it `ftp`, a declared difference, which each one's list of ways it is less strict names. In Envoy's entry: 11 rows on `full`, `portable`, `nginx-auth`, `haproxy-file` and `connection`, and 3 on `two-checks`, `nginx-checks` and `nginx-tracing`, the rows whose keys hold no `client_address`. | +| timeout | `auth.timeout`, `auth.when_unavailable`, `timeouts.idle` | The check holds the request for 3 s, past `auth.timeout`'s 1500 ms, and its `401`, and its `200`, send their body of 100 bytes a byte every 100 ms, so it ends after 10 s. The request reaches the service with the mark of a request the check could not answer under `allow`, and is answered `403` under `deny`, on `two-checks` and `nginx-checks`, after at least 1.45 s and in under 2.95 s, 50 ms inside the two times because the row reads a different clock from the proxy's and the check's (below). With `timeouts.idle`, 2 s on `nginx-file`, `nginx-auth`, `nginx-tracing` and `haproxy-traffic` and 90 s on `full` and `portable`, the rows of the idle time run too. In "a service silent past the idle time" the stub holds its answer for 3 s (`x-stub-delay: 3s`), and Envoy and nginx answer `504` as `text/plain`, Envoy's own text where nginx's own page would be `text/html`, after at least 1.95 s and under 2.95 s (measured at 2.002 to 2.005 s on Envoy 1.40.2 and on nginx), where `full` and `portable` serve it with `200` after 2.95 s or more. In "an answer that pauses less than the idle time" the stub sends the status and headers, then a space after each of two pauses of 1.25 s (`x-stub-trickle: 2x1250ms`), then its echo: each pause is 0.75 s under the idle time and the answer ends 0.5 s past it, so a limit on the whole answer would end it, and every proxy serves it with `200` after at least 2.45 s. In "a request body that pauses past the idle time" a `POST` with `Content-Length: 4` is sent by hand, `ab`, then `cd` after 3 s: Envoy answers `408` after at least 1.95 s, so the row shows the idle time ended it, where nginx closes the connection with no answer, a declared difference on `timeouts.idle`, and `full` and `portable` serve it with `200` and the body `abcd`. Each bound keeps 50 ms from the time it tests, for the two clocks, and the `504` comes within 1 s past the idle time, for a loaded runner. In Envoy's entry: 6 rows on `full`, `portable`, `nginx-auth` and `nginx-tracing`, 3 on `haproxy-file`, `two-checks` and `nginx-checks`, which write no `timeouts.idle`, and 3 on `nginx-file` and `haproxy-traffic`, which write no check. | +| retry | `routes[].retries`, `routes[].rpc.retries` | A request that reached the service is never tried again: a first try the service closes before any answer gives `502`, a gRPC call whose first try is reset gives `grpc-status` `14`, and a `503` from the service is passed on from its first try. A request whose connection a backend refused is tried again on the other: with one of the two shop backends refusing connections, 40 requests to the shop route and 40 gRPC calls to shop are each answered by the other backend; on `nginx-file`, whose shop route writes `retries: 0`, each of the 40 requests to the shop route is answered `502` with no service, as no other backend is tried, or by the backend that is up, and at least one of each, so a proxy that answered every request `502` would fail the row. On `nginx-plain`, whose rpc entry retries once and sends `example.hold.*` to the two backends that take no connection, a call is answered `200` with `grpc-status` `14` after at least 9.95 s and under 10.95 s, the two tries' connect time of 5 s each, and a request to its route `/held/`, which retries once to the same backends, `502` in the same bounds, which a script that found the route's time spent after the first try (`504` at 5 s) or a missing copy for the second try (`500`) fails; on the other files, which list no such method and no such route, both reach the shop route's service. A gRPC call that is not `POST`, a `GET` with gRPC's content type over HTTP/1.1 whose first try the service closes, is answered `200` with `grpc-status` `14` and not tried again. `nginx-auth`, `nginx-checks` and `nginx-plain`, whose shop routes write no retries, get `nginx-file`'s answers there. The rows of a retried route send to `/retried/products/1`, the route `/retried/` of `nginx-file`, `nginx-auth` and `nginx-checks` and the shop route of `full`, which retries; `nginx-plain` serves it by its shop route, which tries each request once, so there each answer is `502` or the other backend's, and at least one of each. nginx reads whole before the first try of a retried route a body with a length of at most 1 MiB and a request with no body, and sends any other, one in chunks among them, as it arrives and tries it once ([nginx](nginx.md#retries)). With one shop backend refusing connections, 40 requests are each answered by the other, and 40 `POST`s with neither `Content-Length` nor `Transfer-Encoding`; of 40 `GET`s whose 180,000 bytes come in one-byte chunks, each reaches the other backend whole through Envoy, which tries it again, and nginx answers `502` each one the refusing backend drew and serves the others, a declared difference; 40 `PUT`s of 1 MiB each reach it whole; of 40 `PUT`s of 1,048,577 bytes, one more than Envoy's buffer for a retry, at least one is answered `507` by Envoy and `502` by nginx, which tries it once, a declared difference; of 40 chunked `PUT`s, and of 40 over HTTP/2 with no content-length, at least one reaches the other backend with its body through Envoy, which tries again a body under its bound, and at least one is answered `502` by nginx, a declared difference. A row that needs the refusing backend drawn, or each backend, sends 40 requests, so a backend drawn at random is missed with a chance of 2^-40. A `PUT` whose first try the service closed once it arrived is answered `502` and not tried again, over HTTP/1.1 and over HTTP/2. A request whose every backend refuses is answered `502` and writes one upstream-failure line, with the flags `URX,UF`, its route and the status `502`, on Envoy and on both nginx versions; the line carries no request id, so the row finds it by route and status among the lines the proxy wrote after the row began. A `PUT` of 1,048,577 bytes with no backend refusing is served once, whole. In Envoy's entry: 19 rows on `full` and `nginx-file`, 18 on `nginx-plain`, which writes no `log`, 15 on `nginx-auth` and `nginx-tracing`, which write no `routes[].rpc.retries`, 15 on `haproxy-traffic`, whose rpc entry writes no retries, and 14 on `nginx-checks`, which writes neither `log` nor `routes[].rpc.retries`; `portable` writes no retries. | +| gRPC | `routes[].rpc`, `routes[].rpc.to`, `routes[].rpc.to.`, `routes[].rpc.to..service`, `rpc.methods`, `rpc.methods[].service`, `rpc.methods[].method`, `rpc.methods[].action`, `rpc.methods[].reports`, `services..grpc`, `auth.ask`, `auth.when_unavailable`, `log` | A method of a package mapped to `shop` reaches shop's gRPC port over HTTP/2 and answers `grpc-status` `0`; a method of any other package reaches `accounts`; the check is told a method's action and reports, and not an action the client sent, and the service receives neither; a gRPC service's `X-Accel-Redirect` is passed on, not followed; a call through a `..` segment reaches the method's path; a call whose service refuses the connection on every backend is answered `200` with `grpc-status` `14`, `content-type` `application/grpc` and no `grpc-message`; a call whose service resets its stream is answered the same, with Envoy's and HAProxy's `grpc-message` naming the reset, where nginx sends none, a declared difference, and a request that is not a gRPC call, sent to that route, `503` with Envoy's text, where nginx and HAProxy answer `502` with no body, a declared difference; a call the check denies is answered in gRPC's form, `200` with `grpc-status` `16` and the denial's body in `grpc-message`, percent-encoded where it holds a `%`, a letter outside ASCII or a line feed. A call the check denies with `403` is answered `200` with `grpc-status` `7`; a call the check cannot answer goes on with the unchecked mark under `allow`, and is answered `200` with `grpc-status` `7` under `deny`; a call whose check's answer cannot be read is a check that could not answer; and a call the check cannot answer logs an unanswered check with the method's action. A call whose accepted header the check sends empty reaches the service with that header empty, where nginx sends a gRPC service none, a declared difference. In Envoy's entry: 16 rows on `full`, `portable`, `nginx-auth` and `nginx-tracing`, 15 on `haproxy-file`, which writes no `log`, 11 on `two-checks` and `nginx-checks`, which write neither that nor `rpc.methods[].action`, and 7 on `nginx-file` and `nginx-plain`, which write no `rpc.methods[].action` and no `auth.ask`. | +| path normalisation | none: it is written for every file ([Written with no key](portability.md#written-with-no-key)) | `..`, `.`, `//`, `%2F` and `%2e%2e` in a path are resolved before a route is picked, and the service hears the normalised path; so are `..` followed by an escaped slash (`..%2f`), by a backslash written as `%5C`, and by a written backslash; `..;` and `.;`, written with dots, resolved as `..` and `.`, which nginx and HAProxy answer `400`, a declared difference; an exact path reached through `..`. An invalid escape, `%zz`, is passed on to the service, whose own `400` answers it, and nginx answers it `400` itself, a declared difference. An escaped `+` and an empty query reach the service as sent; an empty query after a path that needs normalising reaches it after the normalised path, and nginx answers it `400`, a declared difference. A path that still holds a dot segment with a `;` parameter after normalisation answers `400` and reaches no service, the `;` written or escaped once: `/catalog/%2e%2e;/products/1`; `..%3B` and `..%3b`; `.%3B` and `%2e%3b`; dots written escaped, in either case of hex, before an escaped `;`; an escaped `;` with a value or twice over; on the last segment and on the first; between backslashes, written or as `%5C`; and before an escaped slash. These reach the service as sent: a `;` parameter on an ordinary segment, on a name and on a name that starts with a dot; a `;` and an escaped `;` after three dots; an escaped `;` after a name that ends in two dots and inside a name; a `;` escaped twice after `..`; a query that holds `/..;/` or `/..%3B/`; and an escaped `?` after `..`. A dot segment with an escaped `;` that a `..` after it removes reaches the service resolved, and nginx answers it `400`, a declared difference. A path with an empty segment before a dot-dot segment, `/catalog//../products/1`, reaches `catalog` as `/catalog/products/1` through Envoy and HAProxy, where nginx answers `400`, a declared difference, and so does the same path with the slash escaped, `/catalog/%2F../products/1`, and over HTTP/2; an empty segment after a dot-dot segment, `/products/../catalog//items`, reaches `catalog` as `/catalog/items` through every proxy. After the `400` of a dot segment with an escaped `;`, sent with a body that holds a second request and then the client's next request in the same write, Envoy closes the connection and answers no next request, as nginx does, where HAProxy keeps the connection and answers the next request, a declared difference. In Envoy's entry: 47 rows on `full`, `portable`, `nginx-file`, `nginx-plain`, `haproxy-file`, `two-checks`, `nginx-checks`, `nginx-auth` and `nginx-tracing`. | +| the path as the client wrote it | none: it is written for every file ([Written with no key](portability.md#written-with-no-key)) | A path with nothing to normalise, or with only an escape Envoy keeps, is matched and reaches the service as written: `/api/x%3Bv=1/admin`, `/api/a%20b/admin`, `/u/%40bob`, `/l/a%20b` and `/api/a%7cb`, in the case of hex written, where nginx's and HAProxy's own files have patterns that would take the decoded character; `/x%C3%A9` is not taken by the pattern `^/x..$`; an empty query on such a path reaches the service as sent. A path that needs normalising and keeps no escape is matched and sent normalised. A raw `\|` reaches the service as `%7C`. nginx answers `400`, each a declared difference, to a path that needs normalising and keeps an escape, `/api/a%2fb%3bc`; to a byte Envoy escapes beside an escape; to a byte Envoy escapes on `nginx-file`, which has pattern routes; to an escape and to an empty query on a route with a `rewrite`; and to an empty query after a byte Envoy escapes. A `#` in the target is answered `400` over HTTP/1.1 and HTTP/2, where HAProxy resets the HTTP/2 stream, a declared difference, and so is one to a host no environment names, before its `404`. An escaped NUL, `%00`, in the path is answered `400`, and a byte above 0x7F sent raw over HTTP/2 reaches the service escaped, `%C3%A9` for `é`, which nginx answers `400` on `nginx-file`, a declared difference. In Envoy's entry: 21 rows on `full`, `portable`, `nginx-file`, `nginx-plain`, `haproxy-file`, `two-checks`, `nginx-checks`, `nginx-auth` and `nginx-tracing`. | +| an auth-off prefix route | `routes[].prefix`, `routes[].auth`, `auth.ask`, `auth.only_with_header`, `auth.accept`, `auth.send_request` | On `portable`, which sends `/public/` to `shop` with `auth = off` before its other prefix routes: a path under it reaches the service unchecked with a token the check denies, and so does one with a repeated slash, which the service hears merged; a client's own copy of the mark of a request the check could not answer does not reach the service there either. A path that `..`, `%2e%2e`, `..%2f`, `..%5C` or `..\` takes out of `/public/` leaves the route: with a token the check denies it gets the check's `401`, and with a token the check allows it reaches the service, and the check is told the path the service hears, the normalised one; without the normalisation each would stay on the route and reach the service unchecked. `..;` with a token the check denies leaves the route too and gets the check's `401`, and so does an empty segment before a `..`, `/products//../public/readme`, written or, over HTTP/2, escaped, which the `..` removes, where nginx answers `400`, a declared difference. A dot segment with a `;` parameter is answered `400` and reaches no service with no token and with a token the check allows, the `;` written after `%2e%2e` or escaped as `%3B` after `..`. On `full`, which has no such route, the first and the third are answered `401` by the check its shop route asks. A client's own user, question and unchecked mark do not reach the service on that route either, and a request to it logs no check time. In Envoy's entry: 22 rows on `full`, `portable`, `nginx-auth` and `nginx-tracing`, and 21 on `haproxy-file`, which writes no `log`. | +| client keys | `routes[].rate_limit.by` | On `nginx-plain`, whose route `/limited/` admits one request a minute for each client under `client_address: forwarded`, eleven requests to that route, each after the rows before it, so a `200` is a client's first request and a `429` one whose bucket a row before spent: an `X-Forwarded-For` entry with a port, `10.80.0.1:80`, is the peer, so the next request with no entry is answered `429`; an address, `10.80.0.2`, is a client of its own, and the same address with spaces around it is the same client; an IPv6 address in capitals, `FD02::7`, is a client of its own, and `fd02:0::7`, the same address written another way, is the same client; the last entry of a list, `10.99.0.1, 10.80.0.3`, is the client, and that entry alone is the same client; an address in brackets, one with a leading zero and an IPv6 address with a zone are the peer, whose bucket is spent. On every other file that writes a limit's `by`, no route takes `/limited/`, so each request reaches `shop`. In Envoy's entry: 11 rows on `full`, `portable`, `nginx-file`, `nginx-plain`, `nginx-auth` and `nginx-tracing`. | +| hash | `services..hash.header` | On `nginx-file`, whose service `sessions`, at shop's two addresses, picks a backend by the hash of `x-session-id` on the route `/sessions/`, which no rate limit holds: 20 requests with an empty `x-session-id` all reach one backend, an empty header being a value, and so do 20 whose header comes on two lines, `a` and `b`, and 20 whose two lines come as `c` then `d` and as `d` then `c` in turn, which reach different backends when the lines are hashed in the order they came. A value of `x`, 60,000 spaces and `y` is answered within 2 s, where nginx took about 14 s while its script trimmed the value with a regular expression; on `portable`, whose header size nginx reads in buffers of 49,120 bytes, nginx answers that line `400` itself, a declared difference. `full` and `portable` have no such route and send the path to `shop`, either backend. One value of the header sent 20 times reaches one backend every time on `nginx-file` and on `haproxy-traffic`, whose route `/sessions/` hashes it too. In Envoy's entry: 5 rows on `full`, `portable`, `nginx-file` and `haproxy-traffic`. | +| tracing | `tracing`, `tracing.provider.otel`, `tracing.provider.otel.sample.rate`, `tracing.tags..header`, `tracing.tags..env`, `tracing.tags..default`, `tracing.path_in_url`, `auth.ask`, `auth.accept`, `routes[].rpc`, `origins..hosts` | On `nginx-tracing`, which traces 5% of the requests by their `x-request-id` and sends its spans to the battery's collector, each row sends an id the draw picks, `000001f3-...`, or one it does not pick, `000001f4-...`, and reads from the collector the span that carries its id, or finds none, beside what the service received: a request whose id the draw picks is traced, with a `traceparent` marked sampled, and one whose id it does not pick is not; an id that is not a UUID is drawn by its first eight characters, and one shorter than eight is never traced; a client's sampled `traceparent` continues the client's trace, its span the client's span's child, over HTTP/1.1 and HTTP/2, when the draw picks the id, and is sent on not sampled when it does not; one marked not sampled is never traced, and a malformed one reaches the service as sent, a byte 0xFF and each of two lines with its `tracestate` lines included, with no span, over HTTP/1.1 and to a gRPC service; a `traceparent` and a `tracestate` line after a tab are read as Envoy reads them; one of another version than 00 continues the client's trace and keeps the client's `tracestate`, and is sent on not sampled when the draw does not pick the id; two `tracestate` lines reach the service as one, a `tracestate` holding the byte 0xFF reaches the service and the check as sent, Envoy adds an empty `tracestate` when the client sends no `traceparent`, and a client's `tracestate` reaches the span; the check receives the trace, a parent of another version than 00 and one marked not sampled continued, and no trace beside a malformed `traceparent`; a span carries the Envoy output's fields, its `peer.address` is the connection's whatever `X-Forwarded-For` says, and over HTTP/2 its `http.protocol` says so; its `http.url` holds `http` or `https` alone from `X-Forwarded-Proto`, in any letter case, and the host_header of the route's service; a request no route takes and a path the proxy refuses are named `ingress`, and `%00` in the path, a fragment in the target, a refused upgrade and a request line of another scheme than http and https, which is answered `400`, are not traced; a target of 256 bytes is whole in the span, and a query after characters Envoy escapes, a dot-dot segment, a client's `x-envoy-original-path` and a route with a rewrite each give the span the Envoy output's URL; a header tag reads the first of two lines, and every line joined on a header Envoy joins, one sent empty is not set, one absent takes its default, a tag on a header the check accepts reads the value the check accepted, and its default on a route the check is off for, an environment tag whose variable is unset takes its default, and so does one on a variable named like a property every object has, one whose variable is set reads it, and one on a set variable named like such a property reads it through the Envoy output and takes its default through nginx, a value keeps a quote, a backslash and bytes above 0x7F, and a default keeps a dollar, a quote and a backslash; a tag named like a span field replaces it, and keeps the field's value when its header is absent; the tracing headers a client sends do not reach the service; a gRPC call's service receives the span's `traceparent`; a User-Agent after a tab is held by the span without it; a request from a refused origin is traced under its route. nginx's own literals are the differences its rows of `tracing.provider.otel`, `tracing.path_in_url` and `tracing.tags..header` declare: a `traceparent` of another version than 00, or after a tab, is sent on to the service and the check with the client's version and ids and no span, and a `tracestate` after a tab beside a parent gives no span, a User-Agent after a tab gives no span and is sent on not sampled, a gRPC call's malformed `traceparent` on two lines is answered `400`, a target the Envoy output normalises or rewrites, or beside a client's `x-envoy-original-path`, gets no span and is sent on not sampled, and the query after characters Envoy escapes is answered `400` on `nginx-tracing`, whose path nginx refuses, no empty `tracestate` goes with a `traceparent` of nginx's own, the status in a span is a number, a request no route takes has an empty `upstream_cluster`, a refused origin's span is named `ingress`, a target over 256 bytes gets no span, and an empty or absent header tag is set empty. On `full`, which traces 10% with `client_address: connection` to a collector its world leaves unreachable, a row reads what the service received, and nothing the draw decides. In Envoy's entry: 63 rows on `full` and `nginx-tracing`, and 39 on `nginx-tracing-by-name`, which writes no check, no `tracing.tags`, fewer routes, no list of origins and no `host_header`. | +| tracing a retried request | `tracing`, `routes[].retries` | With `shop-2` refusing connections, 40 traced requests to the retried route `/retried/` are each answered by `shop-1` and have one span, named `retried`, with `upstream_cluster` `shop_http` and the status `200`, whose trace and span ids are those of the `traceparent` the service read on the try that served it. In Envoy's entry: 1 row on `full` and `nginx-tracing`. | +| rate limit | `routes[].rate_limit`, `routes[].rate_limit.requests`, `routes[].rate_limit.per`, `routes[].rate_limit.burst`, `routes[].rate_limit.by`, `auth.ask` | After 2.5 s with no request to the route, 60 requests to `/catalog/items` back to back: the first 30 on `full`, `nginx-file` and `nginx-auth` (20 a second and a burst of 10) and the first 20 on `portable` (20 a second and no burst) answer `200`, and at least one of the rest `429`; then, of 60 requests over the limit that carry a token the check denies and one the token filter refuses, at least one is answered `429`, not `401`, so the limit is applied before the token and the check; of 60 `POST`s over the limit with a body of 5 bytes, at least one is answered `429`, and of 60 more with the next request written after the body, at least one ends its connection, so that next request gets no answer (each row after the first sends 60, as a row of 10 that finds the bucket full, which the row before may leave it, gets no `429`); of 60 gRPC calls over HTTP/1.1, told by their content type, with a body and the next request written after it, at least one ends its connection too; of 60 gRPC calls over HTTP/2, at least one is answered `200` with `grpc-status` `8` and `content-type: application/grpc`, and of 60 Connect calls, `POST`s that carry `connect-protocol-version`, at least one `429` with `content-type: application/json`; another route is not limited; and after 2 s with no request to the route, of 40 requests the check denies, the first 30, or 20 on `portable`, are answered `401` and at least one of the rest `429`, so a request the check denies spends a token. On `nginx-file`'s route `/retried-limited/`, which admits 10 requests a minute for all and retries once, with one shop backend refusing connections, the first 10 of 40 requests are answered `200` and at least one of the rest `429`, so a request whose first try was refused spends one token, not two and not none; `full`, `nginx-auth` and `nginx-plain` serve the path by their shop routes, so there at least one answer comes from the backend that is up. In Envoy's entry: 10 rows on `full`, `nginx-auth` and `nginx-tracing`, 9 on `portable`, which writes no retries, 8 on `nginx-file` and `haproxy-traffic`, which write no check, and 2 on `nginx-plain`, whose route `/limited/` has no burst: another route is not limited, and the row of a limited route whose first connections were refused, which its shop route serves. | +| cost | `routes[].pattern`, `routes[].prefix`, `origins..patterns`, `limits.request_headers.size` | A path of 14,000 bytes that 24 pattern routes read, sent with an origin a pattern covers, reaches the prefix route's service with `access-control-allow-origin` within 500 ms, and an `Origin` of 8,000 bytes that 64 patterns of two `*` read is answered `403` within 500 ms; the request after each is served, which only a proxy still running answers. Each stopped HAProxy before its patterns ran in steps and its origin patterns were written so they cannot backtrack ([HAProxy](haproxy.md#what-a-pattern-route-costs)). On `nginx-file` the long path is served as on the other files, nginx's header buffers reading a request line as long as the header limit ([nginx](nginx.md#the-header-limits)), and so is a path of 61,000 bytes, about the longest nginx reads at the file's 60 KiB, a head of 61,133 bytes under the 61,376 it reads ("a path of 61,000 bytes, about the longest nginx reads at 60 KiB, that 24 pattern routes read"): every file but `haproxy-file` serves it with `access-control-allow-origin` within 500 ms, and HAProxy answers `414`, a declared difference; an `Origin` of 6,420 bytes that the last of the 64 patterns takes reaches the service with `access-control-allow-origin`, where HAProxy answers `403` before the service, as it answers any admitted `Origin` longer than it echoes, a declared difference, and one of 6,321 bytes that the 64 read is answered `403`, each within 500 ms on `haproxy-file` and `nginx-file`, the files that name an environment with its host, rows of their own because nginx's first form of the patterns refused the first and held a worker past the bound with the second ([nginx](nginx.md#what-a-pattern-route-and-an-origin-pattern-cost)). More `Origin`s sit past the bound nginx sets on the origin patterns. One of 16,384 bytes that the last of the 64 patterns takes ("an Origin of 16,384 bytes that the last of 64 patterns of two * takes") and one of 16,385 bytes ("an Origin of 16,385 bytes that the last of 64 patterns of two * takes") are served and echoed within 500 ms by Envoy and answered `403` within 500 ms by nginx, which matches no `Origin` longer than 8,192 bytes against the patterns, a declared difference on `origins..patterns`; HAProxy answers both `431`, as it answers any head that outgrows its buffer, a declared difference. A path of 53,005 bytes that the 24 pattern routes read, with an `Origin` of 8,192 bytes that the last pattern takes, the longest nginx matches, in a head of 61,326 bytes ("a path of 53,005 bytes and an Origin of 8,192 bytes that the last of 64 patterns of two * takes, about the longest head nginx reads at 60 KiB"), is served with the `Origin` echoed within 500 ms on `nginx-file` and `nginx-auth`, the files that write `limits.request_headers.size` and name the `Origin`'s host, and answered `404` on `full` and `portable`. On `full` and `portable`, which name no environment with the long `Origin`'s host, each long `Origin` is answered `404`. Then 3,000 requests over 24 connections at once, each to a path of `/k01/` to `/k40/` and 1,000 random `a` and `b`, which 40 pattern routes of `haproxy-file` read, are each served by the prefix route's service, and the proxy's memory, read through Docker's API, grows by less than 96 MiB and 4 MiB for each CPU Docker gives a container, 144 MiB with 12: HAProxy runs a thread for each CPU, and each keeps the states of its own patterns, where Envoy's RE2 keeps a cache for each pattern. On `haproxy-file` with 12 CPUs, HAProxy grew past the bound on the code before the states of a thread shared one budget and with a budget of about 8 MB a thread, and stays under it with the script's, of about 1 MB. It runs on every file that writes pattern and prefix routes, which `haproxy-file`, `nginx-file` and `nginx-auth`, the files with the 40 routes, share with `full` and `portable`. The row logs the memory it read on every run. Last, 2,000 connections are opened as a raw request's would be, over TLS with the client certificate on the files that write `tls`, and each sends the 65 bytes `GET /products/1 HTTP/1.1`, a line break, `Host: localhost`, a line break, `x-pad: ` and 15 `a`, one more than nginx's first header buffer of 64 bytes, and then nothing ("connections each holding a head just over 64 bytes keep the proxy's memory bounded", on `full`, `portable`, `nginx-file` and `nginx-auth`, the files that write `limits.request_headers.size`). The proxy's memory, read through Docker's API before the first connection opens and 3 s after the last, must grow by less than 64 KiB for each connection, 125 MiB for the 2,000, and every connection must still be open with no answer right after. In the eighteen runs whose times are given below, Envoy grew by 27.4 to 33.5 KiB a connection, median 30.6 KiB, and nginx 1.30.6 and 1.31.8 by 23.3 to 26.5 KiB, median 24.7 KiB, on `nginx-auth`, 27.1 to 30.7 KiB, median 28.8 KiB, on `nginx-file` and 48.5 to 52.1 KiB, median 51.2 KiB, on `portable`. One header buffer of 8 MiB in place of nginx's buffers fails the row with 2,000 connections and passes it with 500, so the row keeps 2,000. The row catches that one large buffer only where the kernel's transparent huge pages are `always`, as Docker Desktop's are, because the buffer then takes a whole huge page of 2 MiB; with `madvise` or `never` such a buffer costs the pages a head touches and can pass the row. On every kernel the row bounds the memory a connection holds, and the generator's own test holds the buffers' form. The row logs the memory it read. In Envoy's entry: 12 rows on `full`, `portable`, `nginx-file`, `nginx-auth` and `nginx-tracing`, and 10 on `haproxy-file`, which writes no `limits.request_headers`. | +| connection limit and failed backends | `limits.connections`, `services..health` | On `nginx-limits`, whose limit is two, three requests sent at once on one HTTP/2 connection, each held 1 s by the service: nginx's own `limit_conn` serves two and answers the third `503`, a declared difference, and the Envoy output serves all three. On `full`, whose limit is 4096, all three are served. Then four requests while `shop-2` refuses connections, at least one served, and six right after it takes them again, each served by `shop`: on nginx, whose passive check took `shop-2` out for 10 s, each by `shop-1`, a declared difference. On `haproxy-limits`, whose shop service has one address, HAProxy's own `maxconn` serves two and holds the third in its queue until one ends, so it is answered a second after the others, a declared difference. In Envoy's entry: 3 rows on `full` and `nginx-limits`, and 1 on `haproxy-limits`, the row of the connection limit. | +| traffic keys | `limits.request_headers.size`, `limits.request_headers.count`, `services..health`, `log` | A header block of 50 KiB reaches the service and one of 200 KiB is refused, and 120 header lines reach it and 200 are refused; the files of nginx's battery hold 100 lines, so they refuse 120, and on `portable`, whose 96 KiB nginx reads in buffers of 49,120 bytes, nginx answers the 50 KiB line `400`, a declared difference. With `shop-2` refusing connections, every one of 20 requests to `checked`, checked every second, reaches `shop-1` once 3 s have passed; on `full` the shop route's retry gives the same answers. A request whose service answers `404` is logged; HAProxy's line, of its own `log-format`, holds no path, so the row finds it by its frontend, backend, status, method, version and quoted request id, a declared difference. In Envoy's entry: 6 rows on `full` and `haproxy-traffic`, and 5 on `portable`, `nginx-file`, `nginx-auth` and `nginx-tracing`, all but the health row. | The stub reports each header the service received with its lines joined by a line break, which no value holds, and the bytes of each header whose value is not well-formed UTF-8 in hexadecimal, so a row tells one line holding a comma from @@ -262,7 +275,7 @@ The battery starts every address the files name on one Docker network, so each r | `proxyfile-conformance-hold-2` | `10.0.2.31` | A second listener that never accepts a connection, on 8095, started with the first and as it is: `conformance/testdata/nginx-plain.yaml`'s `held` service has both addresses, so a call its rpc entry retries meets one that takes no connection on each try. | | `proxyfile-conformance-resolver` | `10.0.0.2`, port 53 | The resolver: `catalog.internal.example` is `10.0.2.21`, `collector.internal.example` is `10.0.3.40`, and any other name is NXDOMAIN. | | `proxyfile-conformance-accounts` | `127.0.0.1:7070` in the proxy's own network namespace | `accounts`, HTTP/1.1 and gRPC on one port, and the auth check `auth.ask` names. | -| `proxyfile-conformance-check-1`, `proxyfile-conformance-check-2` | `10.0.3.31`, `10.0.3.32` | `checks`, the check service of `conformance/testdata/two-checks.yaml` and `conformance/testdata/nginx-checks.yaml`, and the first of `conformance/testdata/nginx-connection.yaml`: the stub's `accounts` on 7070 at each address, so a row can make one of the two refuse connections. | +| `proxyfile-conformance-check-1`, `proxyfile-conformance-check-2` | `10.0.3.31`, `10.0.3.32` | `checks`, the check service of `conformance/testdata/two-checks.yaml` and `conformance/testdata/nginx-checks.yaml`, and the first of `conformance/testdata/connection.yaml`: the stub's `accounts` on 7070 at each address, so a row can make one of the two refuse connections. | | `proxyfile-conformance-collector` | `10.0.3.40`, port 4317 | The tracing collector `nginx-tracing.yaml` sends its spans to, and `nginx-tracing-by-name.yaml` by the name `collector.internal.example`, as OTLP over gRPC, started only in those files' worlds, before the proxy. `examples/full` names the same address, which its world leaves unreachable: no request waits for it. | The network is `proxyfile-conformance` on `10.0.0.0/22`, the smallest block that holds every one of these addresses. @@ -295,7 +308,7 @@ and a folded line after them, `allow-fold-after-100` and `1xx-fold-after-100` al `set-cookie` on two of them. `report-removed` and `report-settings` allow and put in `x-user-check` what the check received of the headers a client may not send it (`x-client-id`, `x-user-id` and the mark) and of a client's `HTTP2-Settings`; `allow-empty` allows with no header, so a row sees that the service receives none of an earlier answer's; and -`redirect-relative` answers `302` with a `Location` that is a path, `/login?next=%2Fx`. `deny-401-empty` answers `401` with no body; `chunk-size-lf`, `last-chunk-lf` and `chunk-other-lf` write a bare LF at the end of a chunk-size line, of the last chunk's line and of a chunk's data, a trailer line and the final line; `folded-tab`, `folded-spaces` and `folded-twice` allow with an `x-user-check` that the check folds onto a second line; `accept-past-size` allows with an `x-user-check` of 70,000 bytes, `accept-60000` with one of 60,000 bytes, and `accept-empty` with one that is empty. Thirty-three more tokens write a +`redirect-relative` answers `302` with a `Location` that is a path, `/login?next=%2Fx`. `deny-401-empty` answers `401` with no body; `chunk-size-lf`, `last-chunk-lf` and `chunk-other-lf` write a bare LF at the end of a chunk-size line, of the last chunk's line and of a chunk's data, a trailer line and the final line; `folded-tab`, `folded-spaces` and `folded-twice` allow with an `x-user-check` that the check folds onto a second line; `accept-past-size` allows with an `x-user-check` of 70,000 bytes, `accept-60000` with one of 60,000 bytes, and `accept-empty` with one that is empty. More tokens write a raw answer for the forms nginx's reader of an answer reads in a way of its own, a status line, a header line or a framing that RFC 9112 does not admit, a `304`, a `500`, a `503` with a body, a `599` and a `101`, a header name `x-proxyfile-check`, a denial's header that holds the byte `0xE9`, and bodies of 1 MiB, of one byte more and of 1,100,000 bytes; each `200` of them reports its token in `x-user-check`, so a @@ -325,7 +338,7 @@ Each run makes throwaway TLS files: a self-signed server certificate for `localh clients CA, and a copy of the server certificate as the CA bundle `examples/full`'s `auth.jwt.ca` names. They are written to the folder `proxyfile-conformance` in the system's temporary folder (`$TMPDIR`, or `/tmp`), with the rendered file and the stub's build, and the folder is the user's alone; the proxy reads its `tls` and `jwt` folders -through their own mounts. The three client certificates, one the clients CA signs, one a second CA of the same name +through their own mounts. The client certificates, one the clients CA signs, one a second CA of the same name signs, and one the clients CA signed whose validity ended a day before the run, stay in memory with their keys, so the proxy never sees them and no run writes them to disk. ## What it does not prove @@ -333,7 +346,7 @@ signs, and one the clients CA signed whose validity ended a day before the run, - Answers each proxy writes in its own words. No row checks a local reply's body, or that an answer carries a header a proxy names after itself, which [portability](portability.md) classes as that proxy's own: measured on Envoy 1.40.2, the `403` body `Invalid CORS request`, the empty `502`, the `429` body `local_rate_limited`, and the `403` Envoy - answers when the check answers `204`. A row may check such a header absent, which holds for every proxy, as the two + answers when the check answers `204`. A row may check such a header absent, which holds for every proxy, as the denial rows do. The mark of a request the check could not answer, `x-envoy-auth-failure-mode-allowed`, is checked although it carries Envoy's name, because every proxy writes that name. - A retry of a service with one backend. A row would need the backend to refuse exactly one connection and accept the @@ -344,12 +357,13 @@ signs, and one the clients CA signed whose validity ended a day before the run, among others `auth.jwt` but its `claims`, `timeouts.request` and `timeouts.upstream_idle`. No row sends a valid token, so of `auth.jwt.claims` only the removal of a client's own copy is checked. The table above names every key a scenario exercises. -- Spaces and tabs around a header value over HTTP/1.1. Envoy removes them and nginx passes a tab on, as - [nginx](nginx.md#what-nginx-writes-with-no-key) says, but no row shows it: the stub reads each header through Go's - `net/http`, which removes the spaces and tabs around a value before the stub reports it, so a service behind - every proxy reports the same value. +- Spaces and tabs around a header value over HTTP/1.1. Envoy and HAProxy remove them and nginx passes a tab on, as + [nginx](nginx.md#what-nginx-writes-with-no-key) and + [HAProxy](haproxy.md#where-haproxy-is-less-strict-than-the-envoy-output) say, but no row shows it: the stub reads each + header through Go's `net/http`, which removes the spaces and tabs around a value before the stub reports it, so a + service behind every proxy reports the same value. - What the check is told of the host beyond `Host`. The stub's check reports the method and the path the proxy told it, - and for one token the `Host` and `x-forwarded-proto` it received, not `x-forwarded-host`. + and for the token `report-forwarded` the `Host` and `x-forwarded-proto` it received, not `x-forwarded-host`. ## Running it @@ -369,9 +383,9 @@ answer differs, for example `service: got "shop", want "catalog"`, and the proxy The first run pulls the proxy's image by the digest in [`scripts/envoy-image`](../scripts/envoy-image), the file [`scripts/validate-envoy.sh`](../scripts/validate-envoy.sh) also reads, so an Envoy upgrade changes one line for both; -it pulls nginx's two images by the digests in `scripts/nginx-images` and its two images tagged `-otel` by those in +it pulls nginx's images by the digests in `scripts/nginx-images` and its images tagged `-otel` by those in `scripts/nginx-otel-images`, which [`scripts/validate-nginx.sh`](../scripts/validate-nginx.sh) reads in the same way, -and HAProxy's two by the digests in `scripts/haproxy-images`, which HAProxy's validator, `scripts/validate-haproxy.sh`, +and HAProxy's by the digests in `scripts/haproxy-images`, which HAProxy's validator, `scripts/validate-haproxy.sh`, reads. With the images already pulled and a warm Go build cache, thirty runs of every entry's files, twenty-two worlds in all (one for each file of each entry that starts a proxy: eight in Envoy's entry, five in each nginx entry and two in each HAProxy entry), passed on one arm64 Mac, with Docker giving its containers 12 CPUs, and none waited for another @@ -384,29 +398,32 @@ run and their load was not recorded, and test containers of another program ran on a quiet machine may be faster. Each HAProxy entry took 12.7 to 24.3 s, median 17.6 s, each nginx entry 85.7 to 121.9 s, median 89.0 s, and Envoy's entry 201.0 to 252.5 s, median 206.6 s. A row that waits beside the rest of its scenario (above) is timed from the point the rows in sequence are done, so the row of a service that takes no connection, the -retried request and the retried gRPC call whose tries take no connection, which wait in the same way, and the six rows -over HTTP/2 have no time of their own here; the timeout scenario has no row in sequence, so its rows' times are their -own. The cost scenario's flood took 0.16 to 0.50 s, median 0.22 s, on Envoy's files, 0.16 to 0.50 s, median 0.20 s, on +retried request and the retried gRPC call whose tries take no connection, which wait in the same way, and the rows +over HTTP/2 that wait for Envoy's close have no time of their own here; the timeout scenario has no row in sequence, so +its rows' times are their own. The cost scenario's flood took 0.16 to 0.50 s, median 0.22 s, on Envoy's files, 0.16 to +0.50 s, median 0.20 s, on nginx's and 2.47 to 4.19 s, median 2.86 s, on HAProxy's, each reading the proxy's memory twice through Docker's API in one sample. The rows that bound the time of one answer are the cost scenario's within 500 ms, which took 0.00 to 0.06 s, median 0.00 s, nginx's `400` to a path PCRE2 gives up on, on `nginx-file` and `nginx-auth`, within 50 ms, which took 0.00 to 0.00 s, median 0.00 s, the hash scenario's header of 60,000 spaces between two letters, answered within 2 s, -which took 0.00 to 0.01 s, median 0.00 s, and the auth scenario's two that want a kept-alive connection answered at -once, within 1 s, which took 0.00 to 0.01 s, median 0.00 s. Besides them, ten rows count on time. The rate limit's 60 +which took 0.00 to 0.01 s, median 0.00 s, and the auth scenario's rows that want a kept-alive connection answered at +once, within 1 s, which took 0.00 to 0.01 s, median 0.00 s. Besides them, the rows below count on time. The rate limit's +60 requests must take under 25 ms each on average on `full`, `nginx-file` and `nginx-auth`, which give the catalog route a burst of 10, and under 33 ms on `portable`, which gives it none, because the bucket refills one request every 50 ms and 30 refills on the first three, 40 on `portable`, would admit every request after the first 30 or 20; the 60 took 0.02 to -0.05 s, median 0.03 s, on those three files and 0.02 to 0.07 s, median 0.03 s, on `portable`. The three rows of +0.05 s, median 0.03 s, on those three files and 0.02 to 0.07 s, median 0.03 s, on `portable`. The rows of `auth.timeout` must be answered between 1.45 s and 2.95 s, and took 1.50 to 1.60 s, median 1.51 s, on each file and each -target. Of the three of `timeouts.idle`, the silent service must be answered `504` between 1.95 s and 2.95 s on +target. Of the rows of `timeouts.idle`, the silent service must be answered `504` between 1.95 s and 2.95 s on `nginx-file` and `nginx-auth`, whose idle time is 2 s, and served after 2.95 s on `full` and `portable`, whose idle time is 90 s; the answer that pauses less must end after 2.45 s on each; and Envoy's `408` to the paused body must come after 1.95 s on `nginx-file` and `nginx-auth`. The silent service and the paused body took 2.00 to 2.02 s, median 2.01 s, on `nginx-file` and `nginx-auth` and 3.00 to 3.01 s, median 3.01 s, on `full` and `portable`, and the answer that pauses less 2.50 to 2.53 s, median 2.51 s. A service that takes no connection must be answered `502` on `nginx-plain` between 4.95 s and 5.95 s, a retried request whose two tries take no connection `502` there between 9.95 s and 10.95 s, and a -retried gRPC call whose two tries take no connection `200` with `grpc-status` `14` there in the same bounds. Two rows -count on memory, the flood and the held connections (the cost scenario, above). The flood must grow the proxy by less +retried gRPC call whose two tries take no connection `200` with `grpc-status` `14` there in the same bounds. The rows +that +count on memory are the flood and the held connections (the cost scenario, above). The flood must grow the proxy by less than 144 MiB with the 12 CPUs Docker gives a container, and grew HAProxy 3.2.26 and 3.4.7 by 28 to 35 MiB, median 30.5 MiB, on `haproxy-file`, nginx 1.30.6 and 1.31.8 by 2 to 11 MiB, median 5 MiB, on `nginx-file`, by 1 to 6 MiB, median 2.5 MiB, on `nginx-auth` and, on `portable`, from a fall of 3 MiB to a growth of 3 MiB, median 1 MiB, and Envoy 1.40.2 by 66 @@ -417,12 +434,12 @@ the request on the client's clock, while the proxy times `auth.timeout` on its o 1.5 s timeout and from the check's answer at 3 s; Envoy counts the timeout from the time its event loop last read, from a clock that moves in 1 ms steps under Docker Desktop's kernel, so the client can see the answer up to 1 ms before 1.5 s. A repeated row that fails says how long its requests took. The thirty runs, with every time and memory figure of this -paragraph and the counts of the table below, predate the entries `nginx-otel-1.30` and `nginx-otel-1.31` and the two -files with tracing, which add six worlds, two in each of those entries and two in Envoy's: in one run of the whole +paragraph and the counts of the table below, predate the entries `nginx-otel-1.30` and `nginx-otel-1.31`, the +files with tracing and every file and entry the history above lists after them: in one run of the whole battery, which took 608 s, `nginx-otel-1.30` took 55 s and `nginx-otel-1.31` 55 s, and Envoy's entry took 56 s on `nginx-tracing` and 15 s on `nginx-tracing-by-name`, which took 15 s and 16 s in the other two. -How often each of those rows runs in a run, and in each entry, counted from a log: +How often each of those rows ran in one of those thirty runs, and in each entry, counted from its log: | Rows | In a run | Envoy's entry | Each nginx entry | Each HAProxy entry | |---|---|---|---|---| @@ -479,12 +496,12 @@ says is not published. ## Adding a proxy -A proxy joins in four places, and a row changes for it only where it declares a difference that changes the row's +A proxy joins in the places below, and a row changes for it only where it declares a difference that changes the row's answer (`by`, above): 1. Its generator in `render.Targets` in [`internal/render/render.go`](../internal/render/render.go): the `--target` name, the configuration's file name and the function. `render` and the command line read the targets there. -2. Its declaration of every core key and of the two behaviours written with no key, in a file of its own in +2. Its declaration of every core key and of the behaviours written with no key, in a file of its own in [`internal/format`](../internal/format), listed in `format.Targets` in [`internal/format/support.go`](../internal/format/support.go). A key it does not write yet is declared refused, and a form of a key it refuses, by the key's value or for want of another key, is a `Refuses` entry of that key, which diff --git a/docs/defaults.md b/docs/defaults.md index ac8c10a..534c59e 100644 --- a/docs/defaults.md +++ b/docs/defaults.md @@ -26,7 +26,8 @@ what that is. written. With `forwarded` (`use_remote_address: false`) a proxy stands in front: `X-Forwarded-For` passes as it came, `X-Forwarded-Proto` is kept when present, and with no trusted hops Envoy takes the last `X-Forwarded-For` entry, the one the proxy in front appended, as the client's address. With `connection` (`use_remote_address: true`) the client's - address is the peer of the connection, which Envoy appends to `X-Forwarded-For`, and `X-Forwarded-Proto` is set from + address is the peer of the connection, which Envoy appends to `X-Forwarded-For`, or its own address for a peer on a + loopback address, and `X-Forwarded-Proto` is set from the connection. [The listener](listener.md#the-clients-address) says when to write which. - **A browser origin that is not admitted gets `403` with the body `Invalid CORS request`**, the answer a Spring service gives for a refused origin. Changing it needs a key that does not exist yet. diff --git a/docs/format.md b/docs/format.md index fdf29de..cce24a0 100644 --- a/docs/format.md +++ b/docs/format.md @@ -251,3 +251,13 @@ stands on the line after an anchor. Each problem names its place. 2.2 adds no key. `proxyfile render --target nginx` and `--target haproxy` write nginx's and HAProxy's files ([nginx](nginx.md), [HAProxy](haproxy.md)). + +## After 2.2.0 + +Render every nginx file again after the upgrade, because its `proxyfile.js` changes: the tracing script reads an `env` +tag's variable without asking `process.env` whether it holds the name ([nginx](nginx.md#tracing)). Render an Envoy file +again when it holds `auth.send_request: true` under `client_address: connection`, which a file with `tls` takes when it +writes none: the check is told the connection's scheme, whatever the client writes in the request line, an HTTP/2 +`:scheme` or its own `X-Forwarded-Proto` ([What the check is told](auth.md#what-the-check-is-told)), where 2.2.0 told +it the request's own. Such an nginx file's `nginx.conf` changes too. Until a file is rendered again, `proxyfile check` +reports its 2.2.0 output as different. HAProxy's files do not change. diff --git a/docs/haproxy.md b/docs/haproxy.md index d57b783..0a058cd 100644 --- a/docs/haproxy.md +++ b/docs/haproxy.md @@ -377,15 +377,17 @@ in front. In every case measured on HAProxy 3.2.26 and 3.4.7 beside Envoy 1.40.2, the service received a request the check was asked about only after the check let it through; each case counted the requests the service and the check received. + - **`auth.ask`**: an answer of the check HAProxy cannot read whole is answered 403, where Envoy passes it on: a denial whose header lines and body pass 15,100 bytes, each line counted as its name, its value and 8 bytes, a header line of 16,383 bytes or more, a 200 whose body passes 1 MiB, a head of more than 100 header lines, folded lines not counted, with a name on two of them, where Envoy counts a name it keeps inline, such as date, once, and a status of 101, which a gRPC call gets as grpc-status 7, where Envoy gives 2; an answer in HTTP/1.2, a chunk size of 9 hexadecimal digits or more, a chunk extension or a space or a tab after a chunk size, CR CR LF after a chunk's data or a trailer value, a folded trailer line, two spaces or a tab after the version, a lone CR in the status line or in a header value, a status line of 16,383 bytes or more, or a line other than a chunk-size line whose CR falls at a multiple of 16,384 bytes into the answer (measured at 16,384, 32,768 and 81,920), which HAProxy's socket hands to the script with the CR kept, is answered 403, where Envoy reads it; each head of the answer and its trailer section are read to 81,920 bytes, Envoy's bound, each line counted with a CR and an LF, so lines that end in LF alone reach it sooner; a status outside 100 to 599 or a status line in HTTP/2.0 is answered 403, where Envoy passes the check's status on; the check is sent connection: close on a connection of its own, where Envoy sends no Connection header and keeps its connections to the check open; after a check's 304 HAProxy closes the client's connection, so a request the client sends next on it gets no answer, where Envoy answers it. - **`auth.only_with_header`**: over HTTP/2 a request that carries the header with every value empty is asked, where Envoy does not ask it: HAProxy reads an HTTP/2 value of spaces alone as empty, and Envoy asks one, so HAProxy asks both. - **`auth.send`**: the check receives each byte of 0x80 or more that is not part of well-formed UTF-8 in a header it is sent as the client sent it, where Envoy writes a ! for each such byte. - **`auth.when_unavailable`**: with allow, an answer that breaks off inside its header lines, a chunk-size line or a trailer line, by a close or by passing auth.timeout, a 200 or a denial whose body never ends, an answer whose head or trailer section passes 81,920 bytes, a head of more than 100 header lines with a name on two of them, such as set-cookie, and an answer HAProxy cannot read as RFC 9112 writes one (a Content-Length that is not one line of digits, a control byte in a header value, a status line that does not end, a chunk-size line that ends in a bare LF) are answered 403, where Envoy serves the request with the unchecked mark, x-envoy-auth-failure-mode-allowed: true. -- **`auth.send_request`**: over HTTP/2 a request whose :scheme differs from its connection's scheme is told in x-forwarded-proto the connection's under client_address connection, and under forwarded the x-forwarded-proto it arrived with, or the connection's when it arrived with none, where Envoy tells it the :scheme; under client_address forwarded, an x-forwarded-proto that is neither http nor https, such as ftp, is told as it arrived, where Envoy tells the connection's scheme. -- **`auth.accept`**: an accepted header too large for HAProxy's request buffer is answered 403, where Envoy sets it on the request (the sizes are in HAProxy's row of `auth.accept` in [Portability](portability.md#support-by-proxy-from-the-generators)); a * prefix never sets transfer-encoding, host or te from the check's answer, where Envoy sets each; a folded header line of the check's answer reaches the service joined to the value before it by one space, where Envoy keeps the spaces and tabs of both lines and drops the line end. Two forms are refused at render, naming the key: `auth.accept` naming content-length, transfer-encoding, host, te, connection or upgrade in full is refused by `--target haproxy`: HAProxy frames or routes a request by these headers, so the check's answer never sets them; remove the name from auth.accept. And `auth.accept` holding a * prefix that covers content-length, connection or upgrade is refused by `--target haproxy`: the Envoy output sends the body chunked once Content-Length is removed, and leaves a WebSocket upgrade unanswered once Connection or Upgrade is removed, which HAProxy cannot write; write the other names in full, or a longer prefix, or render it for envoy. -- **`remove_from_clients`**: names and * prefixes that cover none of content-length, connection and upgrade. A value holding content-length, connection or upgrade, in full or under a * prefix, is refused by `--target haproxy`: the Envoy output sends the body chunked once Content-Length is removed, and leaves a WebSocket upgrade unanswered once Connection or Upgrade is removed, which HAProxy cannot write; write the other names in full, or a longer prefix, or render it for envoy. -- **`origins..origins` and `origins..patterns`**: an admitted Origin longer than 872 bytes less the length of cors.expose_headers is answered 403 with the body Invalid CORS request before the check and the service, where the Envoy output echoes it: HAProxy has 1,024 bytes for the lines it adds to an answer. -- **`client_address`**: under forwarded, a client's own X-Request-Id longer than 980 bytes, or than 908 bytes less an echoed Origin and cors.expose_headers, is answered 400 before the check and the service, where the Envoy output serves it: HAProxy echoes the id in the 1,024 bytes it keeps for the lines it adds to an answer; over HTTP/2 an X-Forwarded-Proto of spaces alone is answered 404, where the Envoy output serves it. +- **`auth.send_request`**: under client\_address forwarded, over HTTP/2 a request whose :scheme differs from its connection's scheme is told in x-forwarded-proto the x-forwarded-proto it arrived with, or the connection's when it arrived with none, where Envoy tells it the :scheme, and an x-forwarded-proto that is neither http nor https, such as ftp, is told as it arrived, where Envoy tells the connection's scheme. +- **`auth.accept`**: an accepted header that does not fit beside the request's own header lines in HAProxy's request buffer is answered 403, where Envoy sets it on the request (measured up to 50,000 bytes; it answered 500 at 70,000): beside a request of 118 bytes, one of 8,000 or 15,000 bytes is set by both versions and one of 15,843 bytes or more (3.4.7: 15,851) is answered 403, a bound the request's own header lines lower by as many bytes as they hold; an accepted header whose line reaches 16,383 bytes is answered 403 by auth.ask's line bound first; a \* prefix never sets transfer-encoding, host or te from the check's answer, where Envoy sets each; a folded header line of the check's answer reaches the service joined to the value before it by one space, where Envoy keeps the spaces and tabs of both lines and drops the line end. "auth.accept" naming content-length, transfer-encoding, host, te, connection or upgrade in full is refused by --target haproxy: HAProxy frames or routes a request by these headers, so the check's answer never sets them; remove the name from auth.accept. "auth.accept" holding a \* prefix that covers content-length, connection or upgrade is refused by --target haproxy: the Envoy output sends the body chunked once Content-Length is removed, and leaves a WebSocket upgrade unanswered once Connection or Upgrade is removed, which HAProxy cannot write; write the other names in full, or a longer prefix, or render it for envoy. +- **`remove_from_clients`**: names and \* prefixes that cover none of content-length, connection and upgrade. "remove\_from\_clients" holding content-length, connection or upgrade, in full or under a \* prefix is refused by --target haproxy: the Envoy output sends the body chunked once Content-Length is removed, and leaves a WebSocket upgrade unanswered once Connection or Upgrade is removed, which HAProxy cannot write; write the other names in full, or a longer prefix, or render it for envoy. +- **`origins..origins` and `origins..patterns`**: an admitted Origin longer than 872 bytes less the length of cors.expose\_headers is answered 403 with the body Invalid CORS request before the check and the service, where the Envoy output echoes it: HAProxy has 1,024 bytes for the lines it adds to an answer. +- **`client_address`**: under forwarded, a client's own X-Request-Id longer than 980 bytes, or than 908 bytes less an echoed Origin and cors.expose\_headers, is answered 400 before the check and the service, where the Envoy output serves it: HAProxy echoes the id in the 1,024 bytes it keeps for the lines it adds to an answer; over HTTP/2 an X-Forwarded-Proto of spaces alone is answered 404, where the Envoy output serves it; under connection, a client on a loopback address is appended to X-Forwarded-For as that address, where the Envoy output appends its own address, as Envoy does for every loopback peer (measured with a client at 127.0.0.1 on HAProxy 3.2.26 and 3.4.7 beside Envoy 1.40.2). + - **A dot segment with a `;` parameter answered `400`**: a dot segment whose ; parameter is written with dots, such as /a/..;/b, is answered 400, and a gRPC call 200 with grpc-status 13, where Envoy 1.40 drops the parameter and resolves the segment; with the auth check, such a request is asked about whatever route its resolved path takes, and gets the check's denial or, once the check lets it through, 400, where Envoy asks only when that route is checked and, with send_request, sends the check the resolved path. A client that sends its request and closes its own side never gets the service's answer, on Envoy or on HAProxy. This is @@ -570,11 +572,12 @@ service what Envoy would not, are in [the next section](#where-haproxy-is-less-s ## Where HAProxy is less strict than the Envoy output These differences are not stricter than the Envoy output: in each, HAProxy serves a request the Envoy output refuses or -ends, or sends a service what the Envoy output would not. HAProxy's parsers decide each but the last before any rule of -the file reads the request, its timeout counts the time without data, and no fetch reads a request trailer, which -`option http-drop-request-trailers` removes before the service, so the file cannot close them. A header value that holds -a control byte is not among them: the file refuses it with a rule, as Envoy does, and the entry on a trailer's value is -the one that stays. The last is the file's own: under `client_address: forwarded` it keeps the `X-Forwarded-Proto` a +ends, or sends a service what the Envoy output would not. HAProxy's parsers decide each of the request line's before +any rule of the file reads the request, its timeout counts the time without data, and no fetch reads a request trailer, +which `option http-drop-request-trailers` removes before the service, so the file cannot close them. A header value that +holds a control byte is not among them: the file refuses it with a rule, as Envoy does, and the entry on a trailer's +value is the one that stays. The admin listener's is HAProxy's `monitor-uri`, which answers an absolute target by the +path it names. The last is the file's own: under `client_address: forwarded` it keeps the `X-Forwarded-Proto` a request arrived with, as the Envoy output keeps it for the service, and tells the check that header. `proxyfile render --target haproxy` counts them on standard error after it writes the files, and HAProxy's column in [Portability](portability.md#support-by-proxy-from-the-generators) names each on its row. Measured on HAProxy 3.2.26 and @@ -590,10 +593,18 @@ request arrived with, as the Envoy output keeps it for the service, and tells th - **over HTTP/2, two host fields and no :authority are served**: Over HTTP/2 with no `:authority`, `host: api.example.com` and then `host: evil.example.net` reach the service as the first, and the same host twice as one, where Envoy closes the connection. - **a WebSocket upgrade a service answers without switching passes the service's body**: A WebSocket upgrade a service answers `200` without switching reaches the client with the service's body, where Envoy passes the status and headers with no body. - **a trailer value holding a control byte is served**: A request trailer value holding one of the bytes 0x01 to 0x08, 0x0B, 0x0C, 0x0E to 0x1F or 0x7F is served, the service receiving the body and no trailer, where Envoy answers `400` over HTTP/1.1 and closes the connection over HTTP/2. A header value holding one is answered `400` over HTTP/1.1, as by Envoy, and its stream is reset over HTTP/2, where Envoy closes the connection; HAProxy refuses 0x00, a line feed and a carriage return in either value, with `400` over HTTP/1.1 and a reset stream over HTTP/2. +- **the admin listener serves an absolute target of any scheme as the path it names**: `GET http://localhost/ready HTTP/1.1` with `Host: localhost`, sent to the admin listener, is answered `200` with HAProxy's page `Service ready.`, and so is the same target with `https://`, `HTTP://`, `ftp://` or `ws://`, or with user information, `http://u@localhost/ready`, where the Envoy output's admin listener answers `404` with no body to every absolute target. `http://localhost/nothing` and `http://localhost/ready?x=1` are answered `404` by both, and a target whose host or port is not the Host header's, such as `http://other.example/ready` or `http://localhost:9901/ready`, `400`, where the Envoy output answers `404`. - **without timeouts.request, an answer that keeps arriving runs past 15 s**: Without `timeouts.request`, a service that keeps sending runs past 15 s, where the Envoy output ends a request 15 s after it starts: HAProxy's `timeout server` counts the time without data (on HAProxy 3.4.7, a service that sent one byte a second for 10 s under a 2 s `timeout server` was served). - **under forwarded, an x-forwarded-proto that is neither http nor https is told to the check as it arrived**: With `client_address: forwarded` and `auth.send_request: true`, a request sent over plain HTTP with `X-Forwarded-Proto: ftp`, such as `GET /products/1 HTTP/1.1`, is told `x-forwarded-proto: ftp` in the request to the check, where the Envoy output tells the check `http`, the connection's scheme. Both send the service `X-Forwarded-Proto: ftp`. Under `connection`, over TLS, both tell the check and the service `https`, the connection's scheme. +Two ways [nginx's list](nginx.md#where-nginx-is-less-strict-than-the-envoy-output) names do not hold here (measured on +HAProxy 3.2.26 and 3.4.7 beside Envoy 1.40.2). Under `client_address: connection` an absolute `https` target sent over +plain HTTP, `GET https://localhost/products/1 HTTP/1.1`, is answered `400` and asks no check, as the public listener +answers every absolute target over HTTP/1.1, where the Envoy output answers `403`. A header line sent over HTTP/1.1 as +`X-A:`, a tab and `b5`, or as `X-B: b6` and a tab, reaches the service as `x-a: b5` and `x-b: b6`, as through the Envoy +output, under `forwarded` and under `connection`. + ## What a file holds to load HAProxy reads at most 65 words on a line of its file: it refused a line of 66 with `too many words, truncating after diff --git a/docs/listener.md b/docs/listener.md index 336c839..7a4e3b4 100644 --- a/docs/listener.md +++ b/docs/listener.md @@ -27,7 +27,12 @@ removes from every client request. HTTPS on the public listener is [`tls`](tls.m `X-Forwarded-Proto` from the connection, and on a request it counts as external replaces the client's `x-request-id` and removes the client's own `x-envoy-` headers. It also adds `x-envoy-external-address`, the client's address, to the request the service receives, in place of a client's own copy. Measured on Envoy 1.40.2: a client's forged - `X-Forwarded-For` does not change its address with `connection`, and does with `forwarded`. + `X-Forwarded-For` does not change its address with `connection`, and does with `forwarded`. For a peer on a loopback + address Envoy appends its own address to `X-Forwarded-For` in place of the peer's, where the nginx and HAProxy files + append the peer's: a client at `127.0.0.1` reached the service with Envoy's address on the gateway's network in + `X-Forwarded-For` through the Envoy output and with `127.0.0.1` through the others, and with + `x-envoy-external-address: 127.0.0.1` through all three (measured once on Envoy 1.40.2, nginx 1.30.6 and 1.31.8 and + HAProxy 3.2.26 and 3.4.7). When not written, `client_address` is `connection` in a file that writes [`tls`](tls.md), because a gateway that terminates TLS usually faces its clients, and `forwarded` otherwise, as in every 2.0 file. A gateway that faces its diff --git a/docs/nginx.md b/docs/nginx.md index 5a555a0..c3100f6 100644 --- a/docs/nginx.md +++ b/docs/nginx.md @@ -1336,14 +1336,16 @@ connection's scheme, so a check that decides by the scheme it is told reads the front. In each of the others, a request the check refuses stays refused, and nginx either refuses or holds a request the Envoy output serves, or answers or writes a line otherwise. The words are the words of the declaration. -- **`auth.ask`**: a request whose check answers in one of these forms is answered 403: a status outside 100 to 599, such as 2, 99, 600 or 2000, or 101, where Envoy passes the status on to the client; HTTP/2.0 or HTTP/1.2, two spaces or a tab after the version, a + before the status, a tab between the status and the reason, a lone CR, a space or a tab after a chunk size, a chunk size of nine hex digits, a chunk extension holding a control byte or a quoted CR LF, a chunk-size line past 1,024 bytes, bytes between a chunk's data and its line end, a folded trailer line, or a head of exactly 81,920 bytes with a line in a bare LF, which nginx counts a byte longer, where Envoy reads the answer; a 200 whose body passes 1 MiB, where Envoy serves the request; a denial whose body passes 1 MiB, where Envoy passes the denial on; a denial whose head has more than 100 header lines, folded lines not counted, with a name on two of them, where Envoy counts a name it keeps inline, such as date, once and passes the denial on; over HTTP/2, a gRPC call refused for the check's denial, or with deny for want of a readable answer, is answered as Envoy answers it, with one more header, content-length: 0; a check's 301, 302, 303, 307 or 308 to an HTTP/1.1 request that carries a body reaches the client with nginx's own page in place of the check's body, and a check's 304 to such a request with content-length: 0, as nginx discards the request's body, so that no byte of it is read as the next request; a denial reaches the client with Server: nginx where the check sent no Server header, with nginx's own reason phrase (302 Moved Temporarily, where Envoy writes Found), without a header line the check sent with an empty value, with the check's Access-Control-Allow-Origin beside the listed origin's own, where Envoy sends the origin's alone, and, to a HEAD request, with Content-Length: 0, where Envoy sends transfer-encoding: chunked; an error in proxyfile.js itself as it asks the check or reads its answer is answered 403, with allow too, and writes no log line; the check is sent connection: close on a new connection for each check, where Envoy sends no Connection header and keeps its connections to the check open, so nginx's local ports bound how many checks a second it can send to one check address: near 340,000 a second when the check closes its connection first after it answers, derived from the 0.13% of connections nginx's side then kept in TIME_WAIT and not reached, and about 470 a second when it does not, at most 28,231 checks to one address in any 60 s from the 28,232 ports of 32768 to 60999 (measured on nginx 1.30.6 and 1.31.8 beside Envoy 1.40.2); past that bound a check fails for want of a port, and its request is answered 403 with deny and served with the unchecked mark with allow; the relay listens on a socket file, /run/proxyfile-/check.sock, which nginx removes when it stops and a kill leaves, and nginx then does not start, its bind() to the file failing (98: Address already in use), until the file is removed or /run is a tmpfs. + +- **`auth.ask`**: a request whose check answers in one of these forms is answered 403: a status outside 100 to 599, such as 2, 99, 600 or 2000, or 101, where Envoy passes the status on to the client; HTTP/2.0 or HTTP/1.2, two spaces or a tab after the version, a + before the status, a tab between the status and the reason, a lone CR, a space or a tab after a chunk size, a chunk size of nine hex digits, a chunk extension holding a control byte or a quoted CR LF, a chunk-size line past 1,024 bytes, bytes between a chunk's data and its line end, a folded trailer line, or a head of exactly 81,920 bytes with a line in a bare LF, which nginx counts a byte longer, where Envoy reads the answer; a 200 whose body passes 1 MiB, where Envoy serves the request; a denial whose body passes 1 MiB, where Envoy passes the denial on; a denial whose head has more than 100 header lines, folded lines not counted, with a name on two of them, where Envoy counts a name it keeps inline, such as date, once and passes the denial on; over HTTP/2, a gRPC call refused for the check's denial, or with deny for want of a readable answer, is answered as Envoy answers it, with one more header, content-length: 0; a check's 301, 302, 303, 307 or 308 to an HTTP/1.1 request that carries a body reaches the client with nginx's own page in place of the check's body, and a check's 304 to such a request with content-length: 0, as nginx discards the request's body, so that no byte of it is read as the next request; a denial reaches the client with Server: nginx where the check sent no Server header, with nginx's own reason phrase (302 Moved Temporarily, where Envoy writes Found), without a header line the check sent with an empty value, with the check's Access-Control-Allow-Origin beside the listed origin's own, where Envoy sends the origin's alone, and, to a HEAD request, with Content-Length: 0, where Envoy sends transfer-encoding: chunked; an error in proxyfile.js itself as it asks the check or reads its answer is answered 403, with allow too, and writes no log line; the check is sent connection: close on a new connection for each check, where Envoy sends no Connection header and keeps its connections to the check open, so nginx's local ports bound how many checks a second it can send to one check address: near 340,000 a second when the check closes its connection first after it answers, derived from the 0.13% of connections nginx's side then kept in TIME\_WAIT and not reached, and about 470 a second when it does not, at most 28,231 checks to one address in any 60 s from the 28,232 ports of 32768 to 60999 (measured on nginx 1.30.6 and 1.31.8 beside Envoy 1.40.2); past that bound a check fails for want of a port, and its request is answered 403 with deny and served with the unchecked mark with allow; the relay listens on a socket file, /run/proxyfile-\/check.sock, which nginx removes when it stops and a kill leaves, and nginx then does not start, its bind() to the file failing (98: Address already in use), until the file is removed or /run is a tmpfs. - **`auth.timeout`**: with allow, the request goes on with the unchecked mark at the first byte the check sends after auth.timeout, or after one auth.timeout with no byte from it, so a check that sends a byte just before each auth.timeout of silence holds the request up to twice auth.timeout, where Envoy goes on at auth.timeout. - **`auth.when_unavailable`**: with allow, a request whose check answers in a form Envoy reads as no answer (a malformed header line, framing or status line, a head or a trailer section past the 81,920 bytes Envoy reads, a head of more than 100 header lines with a name on two of them, such as set-cookie, or a body that never ends) is answered 403, where Envoy serves it with the unchecked mark, x-envoy-auth-failure-mode-allowed: true. -- **`auth.only_with_header`**: over HTTP/1.1 a request whose header is a lone tab is asked, where Envoy does not ask it: nginx keeps the tab, which Envoy removes; over HTTP/2 a cookie sent as two or three empty cookie fields is asked, where Envoy does not ask it. One form is refused at render, naming the key: `auth.only_with_header` naming a header that remove_from_clients, auth.accept or the proxy itself removes from clients is refused by `--target nginx`: the Envoy output removes that header before it reads it and never asks the check, where nginx asks it; name a header the proxy passes on. +- **`auth.only_with_header`**: over HTTP/1.1 a request whose header is a lone tab is asked, where Envoy does not ask it: nginx keeps the tab, which Envoy removes; over HTTP/2 a cookie sent as two or three empty cookie fields is asked, where Envoy does not ask it. "auth.only\_with\_header" naming a header that remove\_from\_clients, auth.accept or the proxy itself removes from clients is refused by --target nginx: the Envoy output removes that header before it reads it and never asks the check, where nginx asks it; name a header the proxy passes on. - **`auth.send`**: a client's own x-proxyfile-method and x-proxyfile-path are not sent to the check when send covers them, where Envoy sends them; what the check is asked does not change. -- **`auth.send_request`**: in a file with no pattern route, a path holding a character Envoy escapes before it picks a route (" < > ^ ` { | }) is told in x-forwarded-uri as the client wrote that character, where Envoy tells it escaped; the service receives it escaped from both; over HTTP/2 a request whose :scheme differs from its connection's scheme is told in x-forwarded-proto the connection's under client_address connection, and under forwarded the x-forwarded-proto it arrived with, or the connection's when it arrived with none, where Envoy tells it the :scheme; under client_address connection, so is an absolute target over HTTP/1.1 whose scheme differs from its connection's: an http target sent over TLS is told https, where Envoy tells it http; under client_address forwarded, an x-forwarded-proto that is neither http nor https, such as ftp, is told as it arrived, where Envoy tells the connection's scheme. -- **`auth.accept`**: names written in full, none of them a header nginx writes itself on the request it passes on; a request the accepted headers take past limits.request_headers is answered 500 as by Envoy, counted with the client's own Connection line, its own copies of the headers the proxy sets, each line of a name sent on several lines and each cookie field over HTTP/2, which Envoy drops, replaces or joins into one before it counts, so such a request can be answered 500 by those lines sooner; an accepted header the check sends empty reaches a gRPC service as no header, where Envoy sends it empty. Two forms are refused at render, naming the key: `auth.accept` holding a name with a `*` prefix is refused by `--target nginx`: nginx sets a request header only by a name its configuration writes; write each name in full. And `auth.accept` naming a header nginx frames or routes a request by is refused by `--target nginx`: nginx writes this header itself on the request it passes on, to frame or route it or to keep a client's copy from the service, x-forwarded-for, x-envoy-external-address and the five x-envoy- names Envoy removes from clients only with client_address: connection, and a check service must never change how nginx frames or routes that request; each is refused with either client_address, so a list stays valid when it changes; remove the name from `auth.accept`. -- **`log`**: the request line holds `authz_us` in whole milliseconds, and a request refused for a dot segment with a `;` parameter logs `route` empty on each of its lines, where the Envoy output names the route that refuses it, `refused:dot-segment-with-parameter` ([The request log with the check](#the-request-log-with-the-check)). +- **`auth.send_request`**: in a file with no pattern route, a path holding a character Envoy escapes before it picks a route (" \< > ^ \` { \| }) is told in x-forwarded-uri as the client wrote that character, where Envoy tells it escaped; the service receives it escaped from both; under client\_address forwarded, over HTTP/2 a request whose :scheme differs from its connection's scheme is told in x-forwarded-proto the x-forwarded-proto it arrived with, or the connection's when it arrived with none, where Envoy tells it the :scheme, and an x-forwarded-proto that is neither http nor https, such as ftp, is told as it arrived, where Envoy tells the connection's scheme. +- **`auth.accept`**: names written in full, none of them a header nginx writes itself on the request it passes on; a request the accepted headers take past limits.request\_headers is answered 500 as by Envoy, counted with the client's own Connection line, its own copies of the headers the proxy sets, each line of a name sent on several lines and each cookie field over HTTP/2, which Envoy drops, replaces or joins into one before it counts, so such a request can be answered 500 by those lines sooner; an accepted header the check sends empty reaches a gRPC service as no header, where Envoy sends it empty. "auth.accept" holding a name with a \* prefix is refused by --target nginx: nginx sets a request header only by a name its configuration writes; write each name in full. "auth.accept" naming a header nginx frames or routes a request by is refused by --target nginx: nginx writes this header itself on the request it passes on, to frame or route it or to keep a client's copy from the service, x-forwarded-for, x-envoy-external-address and the five x-envoy- names Envoy removes from clients only with client\_address: connection, and a check service must never change how nginx frames or routes that request; each is refused with either client\_address, so a list stays valid when it changes; remove the name from auth.accept. +- **`log`**: the time is the moment nginx writes the line, in whole seconds with the offset of nginx's time zone (+00:00 in UTC), where the Envoy output writes the request's start in milliseconds with Z; over HTTP/1.1 bytes\_out counts the chunk lines of an answer nginx sends chunked, where the Envoy output counts its body alone; an answer whose status has one, two or four digits, or that has no status line, logs the status 9, where the Envoy output logs the four digits or 502; a status that starts with 0 logs its number without the zeros (050 as 50), one with spaces between its digits the digits joined (2 0 0 as 200) and one with a fraction its whole number (403.1 as 403), each written only when that number is status\_from or above or sample takes the request, where the Envoy output writes 502 whatever status\_from says; bytes\_in counts the whole request, not its body; upstream\_ms counts from the opening of the service connection of the try that answered, not from the request's start; authz\_us counts the check's time in whole milliseconds, 0, 1000, 2000 and so on, where the Envoy output counts microseconds; there are no flags and details fields; a request of a retried route that is not tried again because of its body, longer than 1 MiB or of a length nginx does not know, writes the upstream-failure flag UF after its one try failed, where the Envoy output, which tries it again, writes URX,UF; a value the Envoy output writes null is written empty, but upstream\_ms; a request the origin or upgrade check refuses logs route and upstream empty, where the Envoy output names them; a request refused for a dot segment with a ; parameter logs route empty on each of its lines, where the Envoy output names the route that refuses it, refused:dot-segment-with-parameter; a request Envoy refuses as it reads it logs its host, method, request id and protocol, which Envoy writes null and HTTP/1.1; a request id or Host holding a byte above 0x7F is logged empty. + - **the request line and header names read before a route is picked**: a client that closes its side of the connection right after its request gets nginx's answer when nginx refuses the request itself, an Origin on none of the hosts, a target holding a fragment, a dot segment with a ; parameter or HTTP/1.0, where Envoy closes the connection with no answer. For a request a service answers, each proxy gives the client no answer when it reads the FIN before the service answers, and the service's answer when the answer comes first: with the FIN sent with the request, the service received 148 of 300 such requests through Envoy and 1 and 0 of 300 through nginx 1.30.6 and 1.31.8, and no client got an answer; with the FIN 1 ms later, the service received 298, 297 and 299 of 300, and nearly every client got its answer; with a service that answers 50 ms late, no client got an answer (measured with no `auth` beside Envoy 1.40.2, from the host through Docker's port forwarder). The same rule holds for both proxies, so it is not on the list of ways nginx is less strict. With the check asked it does not hold: a client that half-closed while its check was asked got no answer from either proxy (200 of 200 each), but once the check allowed the request nginx still sent it to the service, 17 and 23 times of 30 when it held idle connections to the service, where the Envoy output sent none; that, with a close and a reset, is on [the list of ways nginx is less strict](#where-nginx-is-less-strict-than-the-envoy-output). ### The request log with the check diff --git a/docs/portability.md b/docs/portability.md index 7900ea2..d607d04 100644 --- a/docs/portability.md +++ b/docs/portability.md @@ -90,13 +90,13 @@ proxy refuses. | Key | Envoy | nginx | HAProxy | |---|---|---|---| | `listen` | supported | supported | supported | -| `admin` | supported | partial: /stats is nginx's seven counters (active connections, accepts, handled, requests, reading, writing and waiting) and /server\_info its version, not Envoy's; any other path or a query is answered 404, where the Envoy output answers 403; TRACE is answered 405 with no body, where the Envoy output answers it as GET; an absolute target nginx or the public listener's checks refuse, as one of a scheme other than http and https, with an empty port, user information or a query right after its host, is answered 400, where the Envoy output answers 404; less strict than the Envoy output: the admin listener serves an absolute target of http or https as the path it names | partial: /ready answers 200 while HAProxy runs, not when the server is ready; no other admin path in this version | +| `admin` | supported | partial: /stats is nginx's seven counters (active connections, accepts, handled, requests, reading, writing and waiting) and /server\_info its version, not Envoy's; any other path or a query is answered 404, where the Envoy output answers 403; TRACE is answered 405 with no body, where the Envoy output answers it as GET; an absolute target nginx or the public listener's checks refuse, as one of a scheme other than http and https, with an empty port, user information or a query right after its host, is answered 400, where the Envoy output answers 404; less strict than the Envoy output: the admin listener serves an absolute target of http or https as the path it names | partial: /ready answers 200 while HAProxy runs, not when the server is ready; no other admin path in this version; an absolute target whose host or port is not the Host header's is answered 400, where the Envoy output answers 404; less strict than the Envoy output: the admin listener serves an absolute target of any scheme as the path it names | | `tls` | supported | partial: plain HTTP sent to the TLS port is answered 400, where the Envoy output closes the connection; from the same ciphers and key exchange groups nginx can choose others for the same client | partial: of the TLS 1.2 suites both take, HAProxy picks by its own order, where Envoy takes the client's among suites it holds equal: a client that offers OpenSSL's default list is given ECDHE-RSA-AES128-GCM-SHA256, where Envoy gives ECDHE-RSA-CHACHA20-POLY1305 | | `tls.certificate` | supported | partial: a path without $; refuses holding $: nginx reads a $ in a certificate's or a key's path as the start of a variable, and a path written to keep the $ is read at each handshake, which nginx -t does not check; put the file at a path without $, or render it for envoy | supported | | `tls.key` | supported | partial: a path without $; refuses holding $: nginx reads a $ in a certificate's or a key's path as the start of a variable, and a path written to keep the $ is read at each handshake, which nginx -t does not check; put the file at a path without $, or render it for envoy | supported | | `tls.clients` | supported | supported | supported | | `tls.clients.ca` | supported | partial: a client certificate that is missing or fails is answered 400 after the handshake, where the Envoy output ends the handshake; a request whose Host names another host than its TLS server name, a host of an environment, is answered 421; neither reaches a service | partial: a client certificate that is not valid yet is refused with the alert bad\_certificate, where Envoy sends certificate\_expired | -| `client_address` | supported | partial: with forwarded, an X-Forwarded-Proto line with no colon is answered 404, where the Envoy output answers 400; less strict than the Envoy output: under connection, an absolute https target sent over plain HTTP is served | partial: under forwarded, a client's own X-Request-Id longer than 980 bytes, or than 908 bytes less an echoed Origin and cors.expose\_headers, is answered 400 before the check and the service, where the Envoy output serves it: HAProxy echoes the id in the 1,024 bytes it keeps for the lines it adds to an answer; over HTTP/2 an X-Forwarded-Proto of spaces alone is answered 404, where the Envoy output serves it | +| `client_address` | supported | partial: with forwarded, an X-Forwarded-Proto line with no colon is answered 404, where the Envoy output answers 400; with connection, a client on a loopback address is appended to X-Forwarded-For as that address, where the Envoy output appends its own address, as Envoy does for every loopback peer (measured with a client at 127.0.0.1 on nginx 1.30.6 and 1.31.8 beside Envoy 1.40.2); less strict than the Envoy output: under connection, an absolute https target sent over plain HTTP is served | partial: under forwarded, a client's own X-Request-Id longer than 980 bytes, or than 908 bytes less an echoed Origin and cors.expose\_headers, is answered 400 before the check and the service, where the Envoy output serves it: HAProxy echoes the id in the 1,024 bytes it keeps for the lines it adds to an answer; over HTTP/2 an X-Forwarded-Proto of spaces alone is answered 404, where the Envoy output serves it; under connection, a client on a loopback address is appended to X-Forwarded-For as that address, where the Envoy output appends its own address, as Envoy does for every loopback peer (measured with a client at 127.0.0.1 on HAProxy 3.2.26 and 3.4.7 beside Envoy 1.40.2) | | `limits` | supported | supported | supported | | `limits.connections` | supported | partial: nginx's own limit\_conn: a request on its way to a service past the number of such requests in flight is answered 503, before its check, if any, is asked, each HTTP/2 stream counted as one and an idle connection as none; an answer the file gives itself, such as a 404 or a preflight's 200, is neither counted nor refused, and no line limits a service's connections; refuses above 65535: nginx's limit\_conn takes at most 65535; write 65535 or less, or render it for envoy | partial: HAProxy's own maxconn on the listener and on each server: a connection past it waits in the listen queue, and a request past a server's waits up to 5 s in HAProxy's queue and is then answered 503; the limit to a service counts on each of its addresses | | `limits.request_headers` | supported | supported | supported | @@ -134,7 +134,7 @@ proxy refuses. | `auth.only_with_header` | supported | partial: over HTTP/1.1 a request whose header is a lone tab is asked, where Envoy does not ask it: nginx keeps the tab, which Envoy removes; over HTTP/2 a cookie sent as two or three empty cookie fields is asked, where Envoy does not ask it; refuses naming a header that remove\_from\_clients, auth.accept or the proxy itself removes from clients: the Envoy output removes that header before it reads it and never asks the check, where nginx asks it; name a header the proxy passes on | partial: over HTTP/2 a request that carries the header with every value empty is asked, where Envoy does not ask it: HAProxy reads an HTTP/2 value of spaces alone as empty, and Envoy asks one, so HAProxy asks both | | `auth.send` | supported | partial: a client's own x-proxyfile-method and x-proxyfile-path are not sent to the check when send covers them, where Envoy sends them; what the check is asked does not change | partial: the check receives each byte of 0x80 or more that is not part of well-formed UTF-8 in a header it is sent as the client sent it, where Envoy writes a ! for each such byte | | `auth.accept` | supported | partial: names written in full, none of them a header nginx writes itself on the request it passes on; a request the accepted headers take past limits.request\_headers is answered 500 as by Envoy, counted with the client's own Connection line, its own copies of the headers the proxy sets, each line of a name sent on several lines and each cookie field over HTTP/2, which Envoy drops, replaces or joins into one before it counts, so such a request can be answered 500 by those lines sooner; an accepted header the check sends empty reaches a gRPC service as no header, where Envoy sends it empty; refuses holding a name with a \* prefix: nginx sets a request header only by a name its configuration writes; write each name in full; refuses naming a header nginx frames or routes a request by: nginx writes this header itself on the request it passes on, to frame or route it or to keep a client's copy from the service, x-forwarded-for, x-envoy-external-address and the five x-envoy- names Envoy removes from clients only with client\_address: connection, and a check service must never change how nginx frames or routes that request; each is refused with either client\_address, so a list stays valid when it changes; remove the name from auth.accept | partial: an accepted header that does not fit beside the request's own header lines in HAProxy's request buffer is answered 403, where Envoy sets it on the request (measured up to 50,000 bytes; it answered 500 at 70,000): beside a request of 118 bytes, one of 8,000 or 15,000 bytes is set by both versions and one of 15,843 bytes or more (3.4.7: 15,851) is answered 403, a bound the request's own header lines lower by as many bytes as they hold; an accepted header whose line reaches 16,383 bytes is answered 403 by auth.ask's line bound first; a \* prefix never sets transfer-encoding, host or te from the check's answer, where Envoy sets each; a folded header line of the check's answer reaches the service joined to the value before it by one space, where Envoy keeps the spaces and tabs of both lines and drops the line end; refuses naming content-length, transfer-encoding, host, te, connection or upgrade in full: HAProxy frames or routes a request by these headers, so the check's answer never sets them; remove the name from auth.accept; refuses holding a \* prefix that covers content-length, connection or upgrade: the Envoy output sends the body chunked once Content-Length is removed, and leaves a WebSocket upgrade unanswered once Connection or Upgrade is removed, which HAProxy cannot write; write the other names in full, or a longer prefix, or render it for envoy | -| `auth.send_request` | supported | partial: in a file with no pattern route, a path holding a character Envoy escapes before it picks a route (" \< > ^ \` { \| }) is told in x-forwarded-uri as the client wrote that character, where Envoy tells it escaped; the service receives it escaped from both; over HTTP/2 a request whose :scheme differs from its connection's scheme is told in x-forwarded-proto the connection's under client\_address connection, and under forwarded the x-forwarded-proto it arrived with, or the connection's when it arrived with none, where Envoy tells it the :scheme; under client\_address connection, so is an absolute target over HTTP/1.1 whose scheme differs from its connection's: an http target sent over TLS is told https, where Envoy tells it http; under client\_address forwarded, an x-forwarded-proto that is neither http nor https, such as ftp, is told as it arrived, where Envoy tells the connection's scheme; less strict than the Envoy output: under forwarded, an x-forwarded-proto that is neither http nor https is told to the check as it arrived | partial: over HTTP/2 a request whose :scheme differs from its connection's scheme is told in x-forwarded-proto the connection's under client\_address connection, and under forwarded the x-forwarded-proto it arrived with, or the connection's when it arrived with none, where Envoy tells it the :scheme; under client\_address forwarded, an x-forwarded-proto that is neither http nor https, such as ftp, is told as it arrived, where Envoy tells the connection's scheme; less strict than the Envoy output: under forwarded, an x-forwarded-proto that is neither http nor https is told to the check as it arrived | +| `auth.send_request` | supported | partial: in a file with no pattern route, a path holding a character Envoy escapes before it picks a route (" \< > ^ \` { \| }) is told in x-forwarded-uri as the client wrote that character, where Envoy tells it escaped; the service receives it escaped from both; under client\_address forwarded, over HTTP/2 a request whose :scheme differs from its connection's scheme is told in x-forwarded-proto the x-forwarded-proto it arrived with, or the connection's when it arrived with none, where Envoy tells it the :scheme, and an x-forwarded-proto that is neither http nor https, such as ftp, is told as it arrived, where Envoy tells the connection's scheme; less strict than the Envoy output: under forwarded, an x-forwarded-proto that is neither http nor https is told to the check as it arrived | partial: under client\_address forwarded, over HTTP/2 a request whose :scheme differs from its connection's scheme is told in x-forwarded-proto the x-forwarded-proto it arrived with, or the connection's when it arrived with none, where Envoy tells it the :scheme, and an x-forwarded-proto that is neither http nor https, such as ftp, is told as it arrived, where Envoy tells the connection's scheme; less strict than the Envoy output: under forwarded, an x-forwarded-proto that is neither http nor https is told to the check as it arrived | | `auth.jwt` | supported | refused: nginx open source cannot verify a token (nginx Plus's auth\_jwt); verify it in the service, or render it for envoy | refused: HAProxy's jwt\_verify takes one key file, with no key set, URL, issuer or audience check; verify the token in the service auth.ask names | | `auth.jwt.issuer` | supported | refused: nginx open source cannot verify a token (nginx Plus's auth\_jwt); verify it in the service, or render it for envoy | refused: HAProxy's jwt\_verify takes one key file, with no key set, URL, issuer or audience check; verify the token in the service auth.ask names | | `auth.jwt.audiences` | supported | refused: nginx open source cannot verify a token (nginx Plus's auth\_jwt); verify it in the service, or render it for envoy | refused: HAProxy's jwt\_verify takes one key file, with no key set, URL, issuer or audience check; verify the token in the service auth.ask names | diff --git a/examples/full/hocon/envoy.yaml b/examples/full/hocon/envoy.yaml index 45c30ca..78cfca5 100644 --- a/examples/full/hocon/envoy.yaml +++ b/examples/full/hocon/envoy.yaml @@ -242,7 +242,7 @@ static_resources: server_uri: {uri: "http://127.0.0.1:7070/auth/check", cluster: "accounts_http", timeout: 1.5s} path_override: "/auth/check" authorization_request: - headers_to_add: [{key: x-gateway-timeout-ms, value: "1500"}, {key: x-forwarded-uri, value: "%REQ(:PATH)%"}, {key: x-forwarded-method, value: "%REQ(:METHOD)%"}, {key: x-forwarded-proto, value: "%REQ(:SCHEME)%"}, {key: x-forwarded-host, value: "%REQ(:AUTHORITY)%"}] + headers_to_add: [{key: x-gateway-timeout-ms, value: "1500"}, {key: x-forwarded-uri, value: "%REQ(:PATH)%"}, {key: x-forwarded-method, value: "%REQ(:METHOD)%"}, {key: x-forwarded-proto, value: "https"}, {key: x-forwarded-host, value: "%REQ(:AUTHORITY)%"}] authorization_response: allowed_upstream_headers: patterns: diff --git a/examples/full/yaml/envoy.yaml b/examples/full/yaml/envoy.yaml index 45c30ca..78cfca5 100644 --- a/examples/full/yaml/envoy.yaml +++ b/examples/full/yaml/envoy.yaml @@ -242,7 +242,7 @@ static_resources: server_uri: {uri: "http://127.0.0.1:7070/auth/check", cluster: "accounts_http", timeout: 1.5s} path_override: "/auth/check" authorization_request: - headers_to_add: [{key: x-gateway-timeout-ms, value: "1500"}, {key: x-forwarded-uri, value: "%REQ(:PATH)%"}, {key: x-forwarded-method, value: "%REQ(:METHOD)%"}, {key: x-forwarded-proto, value: "%REQ(:SCHEME)%"}, {key: x-forwarded-host, value: "%REQ(:AUTHORITY)%"}] + headers_to_add: [{key: x-gateway-timeout-ms, value: "1500"}, {key: x-forwarded-uri, value: "%REQ(:PATH)%"}, {key: x-forwarded-method, value: "%REQ(:METHOD)%"}, {key: x-forwarded-proto, value: "https"}, {key: x-forwarded-host, value: "%REQ(:AUTHORITY)%"}] authorization_response: allowed_upstream_headers: patterns: diff --git a/examples/portable/hocon/envoy.yaml b/examples/portable/hocon/envoy.yaml index 1f3032b..c92269b 100644 --- a/examples/portable/hocon/envoy.yaml +++ b/examples/portable/hocon/envoy.yaml @@ -185,7 +185,7 @@ static_resources: server_uri: {uri: "http://127.0.0.1:7070/auth/check", cluster: "accounts_http", timeout: 1.5s} path_override: "/auth/check" authorization_request: - headers_to_add: [{key: x-gateway-timeout-ms, value: "1500"}, {key: x-forwarded-uri, value: "%REQ(:PATH)%"}, {key: x-forwarded-method, value: "%REQ(:METHOD)%"}, {key: x-forwarded-proto, value: "%REQ(:SCHEME)%"}, {key: x-forwarded-host, value: "%REQ(:AUTHORITY)%"}] + headers_to_add: [{key: x-gateway-timeout-ms, value: "1500"}, {key: x-forwarded-uri, value: "%REQ(:PATH)%"}, {key: x-forwarded-method, value: "%REQ(:METHOD)%"}, {key: x-forwarded-proto, value: "https"}, {key: x-forwarded-host, value: "%REQ(:AUTHORITY)%"}] authorization_response: allowed_upstream_headers: patterns: diff --git a/examples/portable/yaml/envoy.yaml b/examples/portable/yaml/envoy.yaml index 1f3032b..c92269b 100644 --- a/examples/portable/yaml/envoy.yaml +++ b/examples/portable/yaml/envoy.yaml @@ -185,7 +185,7 @@ static_resources: server_uri: {uri: "http://127.0.0.1:7070/auth/check", cluster: "accounts_http", timeout: 1.5s} path_override: "/auth/check" authorization_request: - headers_to_add: [{key: x-gateway-timeout-ms, value: "1500"}, {key: x-forwarded-uri, value: "%REQ(:PATH)%"}, {key: x-forwarded-method, value: "%REQ(:METHOD)%"}, {key: x-forwarded-proto, value: "%REQ(:SCHEME)%"}, {key: x-forwarded-host, value: "%REQ(:AUTHORITY)%"}] + headers_to_add: [{key: x-gateway-timeout-ms, value: "1500"}, {key: x-forwarded-uri, value: "%REQ(:PATH)%"}, {key: x-forwarded-method, value: "%REQ(:METHOD)%"}, {key: x-forwarded-proto, value: "https"}, {key: x-forwarded-host, value: "%REQ(:AUTHORITY)%"}] authorization_response: allowed_upstream_headers: patterns: diff --git a/internal/cli/cli_test.go b/internal/cli/cli_test.go index 16d7c5b..f26b721 100644 --- a/internal/cli/cli_test.go +++ b/internal/cli/cli_test.go @@ -60,7 +60,7 @@ func TestRun(t *testing.T) { // print nothing. {name: "render for haproxy counts the ways it is less strict", setup: copyMinimal, args: "render /yaml/proxyfile.yaml -o /haproxy.cfg --target haproxy", - stderr: "proxyfile render: this HAProxy configuration is less strict than the Envoy output in 11 ways; " + + stderr: "proxyfile render: this HAProxy configuration is less strict than the Envoy output in 12 ways; " + "docs/haproxy.md lists them under \"Where HAProxy is less strict than the Envoy output\"\n"}, {name: "render for nginx counts the ways it is less strict", setup: func(t *testing.T, tmp string) { copyExample(t, tmp, "grpc") }, args: "render /yaml/proxyfile.yaml -o /nginx.conf --target nginx", diff --git a/internal/envoy/fragments/filter-ext-authz.yaml b/internal/envoy/fragments/filter-ext-authz.yaml index 73cb3b0..48891b8 100644 --- a/internal/envoy/fragments/filter-ext-authz.yaml +++ b/internal/envoy/fragments/filter-ext-authz.yaml @@ -32,12 +32,17 @@ typed_config: # # With send_request, the request the check judges, in the four headers forward-auth services read: its path # and query, its method, its scheme and its host. headers_to_add sets each one, so a client's own copy of - # x-forwarded-uri, x-forwarded-method or x-forwarded-host never reaches the check, also when send names it; - # the scheme is the request's, which with use_remote_address false comes from the X-Forwarded-Proto it - # arrived with (measured on Envoy 1.40.2). + # x-forwarded-uri, x-forwarded-method or x-forwarded-host never reaches the check, also when send names it. + # Under client_address connection the scheme is the listener's, https with tls and http without, because the + # client writes the request line and an HTTP/2 :scheme: the request's own scheme told the check https for an + # HTTP/2 request with :scheme https sent over plain HTTP, and http for an absolute http target sent over TLS + # (measured on Envoy 1.40.2). The X-Forwarded-Proto Envoy sets from the connection gave the same words; the + # scheme written as text reads no header at all. Under forwarded the scheme is the request's, which with + # use_remote_address false comes from the X-Forwarded-Proto it arrived with (measured on Envoy 1.40.2). headers_to_add: [{key: x-gateway-timeout-ms, value: "{{.Check.TimeoutMillis}}"} {{- if .Check.SendRequest}}, {key: x-forwarded-uri, value: "%REQ(:PATH)%"}, - {key: x-forwarded-method, value: "%REQ(:METHOD)%"}, {key: x-forwarded-proto, value: "%REQ(:SCHEME)%"}, + {key: x-forwarded-method, value: "%REQ(:METHOD)%"}, + {key: x-forwarded-proto, value: "{{with .Check.ConnectionScheme}}{{.}}{{else}}%REQ(:SCHEME)%{{end}}"}, {key: x-forwarded-host, value: "%REQ(:AUTHORITY)%"} {{- end}}] {{- with .Check.Accept}} diff --git a/internal/envoy/generate.go b/internal/envoy/generate.go index 5dfb156..079d495 100644 --- a/internal/envoy/generate.go +++ b/internal/envoy/generate.go @@ -357,20 +357,30 @@ func check(g *model.Gateway) data { } service := g.Service(a.Service.Value) port, _ := service.Port(model.HTTP) + // Under connection every connection the listener takes is of one scheme, which the check is told in place of the + // one the client wrote (filter-ext-authz.yaml); under forwarded it stays empty, and the request's own is told. + var connectionScheme string + if g.ClientAddress == model.ClientConnection { + connectionScheme = "http" + if g.TLS != nil { + connectionScheme = "https" + } + } return data{ // JoinHostPort writes an IPv6 address in brackets, as a URI needs it. ext_authz never sends the uri, so the first // backend names it whatever the number of backends. - "URI": "http://" + net.JoinHostPort(service.Addresses[0].Value, strconv.FormatInt(port.Number, 10)) + a.Path, - "Cluster": service.Cluster(model.HTTP), - "Path": a.Path, - "Timeout": model.FormatSeconds(a.Timeout.Millis), - "TimeoutMillis": a.Timeout.Millis, - "Enabled": a.Enabled, - "Allow": a.Allow, - "OnlyWithHeader": a.OnlyWithHeader, - "Send": a.Send, - "Accept": a.Accept, - "SendRequest": a.SendRequest, + "URI": "http://" + net.JoinHostPort(service.Addresses[0].Value, strconv.FormatInt(port.Number, 10)) + a.Path, + "Cluster": service.Cluster(model.HTTP), + "Path": a.Path, + "Timeout": model.FormatSeconds(a.Timeout.Millis), + "TimeoutMillis": a.Timeout.Millis, + "Enabled": a.Enabled, + "Allow": a.Allow, + "OnlyWithHeader": a.OnlyWithHeader, + "Send": a.Send, + "Accept": a.Accept, + "SendRequest": a.SendRequest, + "ConnectionScheme": connectionScheme, } } diff --git a/internal/format/docs_test.go b/internal/format/docs_test.go index 05ad23b..7394dd7 100644 --- a/internal/format/docs_test.go +++ b/internal/format/docs_test.go @@ -38,7 +38,7 @@ func TestDocsAreCurrent(t *testing.T) { continue } if text[table.start:table.end] != want && !*update { - t.Errorf("%s: the table of %q differs from what Reference or SupportMatrix writes; rewrite it with "+ + t.Errorf("%s: the block of %q differs from what the description and the targets' declarations write; rewrite it with "+ "go test ./internal/format -run TestDocsAreCurrent -update", file, table.name) } current.WriteString(want) @@ -242,8 +242,10 @@ func keyTables(text string) ([]keyTable, error) { // tableNamed returns the table a marker names: "." holds the keys at the top of a proxyfile that hold no keys of // their own, "origins file" and "methods file" the keys of those files, "support by proxy" each target's support of // every row of MatrixRows, "less strict: " the list of the ways that target is less strict than the Envoy -// output, and any other name is the path of a key of the proxyfile, whose table holds that key and every key under it, -// in the class of the key that holds it. +// output, "notes: : , " the list of that target's notes on those rows of MatrixRows (NoteList), +// "render warning: " the line render prints after it writes that target's files, as a code block, and any +// other name is the path of a key of the proxyfile, whose table holds that key and every key under it, in the class of +// the key that holds it. func tableNamed(name string) (string, error) { if target, found := strings.CutPrefix(name, "less strict: "); found { t, known := TargetNamed(target) @@ -252,6 +254,23 @@ func tableNamed(name string) (string, error) { } return string(LessStrictList(t)), nil } + if rest, found := strings.CutPrefix(name, "notes: "); found { + target, rows, _ := strings.Cut(rest, ": ") + t, known := TargetNamed(target) + if !known { + return "", fmt.Errorf("a list of notes names %q, which is no target", target) + } + notes, err := NoteList(t, strings.Split(rows, ", ")) + return string(notes), err + } + if target, found := strings.CutPrefix(name, "render warning: "); found { + t, known := TargetNamed(target) + if !known || LessStrictWarning(t) == "" { + return "", fmt.Errorf("a render warning names %q, which is no target whose render prints one", target) + } + // The prefix is the one cli.Run writes before the warning, which internal/cli's tests pin. + return "```\nproxyfile render: " + LessStrictWarning(t) + "\n```\n", nil + } switch name { case ".": leaves := slices.DeleteFunc(slices.Clone(Proxyfile.Fields), holdsKeys) diff --git a/internal/format/support.go b/internal/format/support.go index 1f01cdf..ef3cf33 100644 --- a/internal/format/support.go +++ b/internal/format/support.go @@ -174,6 +174,44 @@ func LessStrictList(t Target) []byte { return []byte(b.String()) } +// NoteList writes the notes of t on rows as the Markdown list its page holds: each row's name in bold, a key in code and +// a row written with no key in its words, then its note, escaped as the support table escapes it, and each form of it +// t refuses in the words render prints (FormRefusedMessage), which name one key. Rows side by side that refuse no form +// and share a note share one item. The page reads on its own with these words, and TestDocsAreCurrent keeps them the +// declaration's, so a note changed there cannot leave the page's copy behind. A row t does not declare partial has no +// note to give. +func NoteList(t Target, rows []string) ([]byte, error) { + var b strings.Builder + for i := 0; i < len(rows); { + support := t.Keys[rows[i]] + if support.Level != Partial { + return nil, fmt.Errorf("a list of notes names %q, which %s does not declare partial", rows[i], t.Name) + } + end := i + 1 + for end < len(rows) && support.Refuses == nil { + next := t.Keys[rows[end]] + if next.Level != support.Level || next.Note != support.Note || next.Refuses != nil { + break + } + end++ + } + names := make([]string, end-i) + for j, row := range rows[i:end] { + names[j] = "`" + row + "`" + if slices.Contains(WrittenWithNoKey, row) { + names[j] = escape(row) + } + } + b.WriteString("- **" + strings.Join(names, " and ") + "**: " + escape(support.Note) + ".") + for _, refusal := range support.Refuses { + b.WriteString(" " + escape(FormRefusedMessage(rows[i], refusal.Form, t.Name, refusal.Instead)) + ".") + } + b.WriteString("\n") + i = end + } + return []byte(b.String()), nil +} + // LessStrictHeading is the heading of the section of t's page that lists its less strict ways. func LessStrictHeading(t Target) string { return "Where " + t.Title + " is less strict than the Envoy output" diff --git a/internal/format/support_haproxy.go b/internal/format/support_haproxy.go index a211273..8638ed5 100644 --- a/internal/format/support_haproxy.go +++ b/internal/format/support_haproxy.go @@ -122,7 +122,7 @@ var haproxyTarget = Target{Name: "haproxy", Title: "HAProxy", Keys: map[string]S // monitor-uri answers 200 while the process runs, where Envoy's /ready reports the server's state (HAProxy 3.4 // configuration manual, monitor-uri). - "admin": {Level: Partial, Note: "/ready answers 200 while HAProxy runs, not when the server is ready; no other admin path in this version"}, + "admin": {Level: Partial, Note: "/ready answers 200 while HAProxy runs, not when the server is ready; no other admin path in this version; an absolute target whose host or port is not the Host header's is answered 400, where the Envoy output answers 404"}, // The versions, the suites and the key exchange groups are Envoy's (measured on HAProxy 3.2.26 and 3.4.7 beside // Envoy 1.40.2 with openssl s_client, one version, suite and group at a time); OpenSSL has no suites of equal @@ -139,9 +139,13 @@ var haproxyTarget = Target{Name: "haproxy", Title: "HAProxy", Keys: map[string]S // for the lines it adds, beside an echoed Origin: an id that outgrew them got 500 after the service did the work, // so the file refuses one longer than the room left before the check and the service. HAProxy's HTTP/2 decoder drops // the spaces of a value, so X-Forwarded-Proto of spaces alone reads as empty. Measured on HAProxy 3.2.26 and 3.4.7 - // beside Envoy 1.40.2 (haproxy.cfg.tmpl, idRoom in generate.go). + // beside Envoy 1.40.2 (haproxy.cfg.tmpl, idRoom in generate.go). Under connection the file appends the peer's + // address, %[src], whatever it is, where Envoy's connection manager appends its own local address for a peer on a + // loopback address (Envoy 1.40.2, conn_manager_utility.cc). The address the file sends is the client's, and the + // battery cannot send from a loopback address, so it was measured once, in a rig whose client ran in the proxy's + // network namespace. "client_address": {Level: Partial, - Note: "under forwarded, a client's own X-Request-Id longer than 980 bytes, or than 908 bytes less an echoed Origin and cors.expose_headers, is answered 400 before the check and the service, where the Envoy output serves it: HAProxy echoes the id in the 1,024 bytes it keeps for the lines it adds to an answer; over HTTP/2 an X-Forwarded-Proto of spaces alone is answered 404, where the Envoy output serves it"}, + Note: "under forwarded, a client's own X-Request-Id longer than 980 bytes, or than 908 bytes less an echoed Origin and cors.expose_headers, is answered 400 before the check and the service, where the Envoy output serves it: HAProxy echoes the id in the 1,024 bytes it keeps for the lines it adds to an answer; over HTTP/2 an X-Forwarded-Proto of spaces alone is answered 404, where the Envoy output serves it; under connection, a client on a loopback address is appended to X-Forwarded-For as that address, where the Envoy output appends its own address, as Envoy does for every loopback peer (measured with a client at 127.0.0.1 on HAProxy 3.2.26 and 3.4.7 beside Envoy 1.40.2)"}, "limits": {Level: Supported}, // maxconn on a server queues the requests past it, for timeout queue, which takes timeout connect's 5 s when not @@ -274,13 +278,15 @@ var haproxyTarget = Target{Name: "haproxy", Title: "HAProxy", Keys: map[string]S Instead: "HAProxy frames or routes a request by these headers, so the check's answer never sets them; remove the name from auth.accept", Applies: func(value, _ *tree.Node) bool { whole, _ := coveredBy(value, HAProxyFramedBy); return whole }}, haproxyRemovalPrefix}}, - // The check is told the scheme of the client's connection (measured on HAProxy 3.2.26 and 3.4.7 beside Envoy - // 1.40.2, :scheme http over TLS and https without). Under forwarded the script tells it the X-Forwarded-Proto the - // request arrived with, which the file keeps as Envoy keeps it for the service: X-Forwarded-Proto: ftp is told ftp, - // where the Envoy output tells the connection's scheme (the battery's row "an x-forwarded-proto that is neither http - // nor https", on two-checks). + // Under connection the file and the Envoy output tell the check the connection's scheme, whatever an HTTP/2 + // :scheme or a client's X-Forwarded-Proto names (the battery's scenario of the scheme the check is told, on + // haproxy-file and connection.yaml). Under forwarded the script tells it the X-Forwarded-Proto the request arrived + // with, or the connection's scheme without one, and never the :scheme (measured on HAProxy 3.2.26 and 3.4.7 beside + // Envoy 1.40.2), which the file keeps as Envoy keeps it for the service: X-Forwarded-Proto: ftp is told ftp, where + // the Envoy output tells the connection's scheme (the battery's row "an x-forwarded-proto that is neither http nor + // https", on two-checks). "auth.send_request": {Level: Partial, - Note: "over HTTP/2 a request whose :scheme differs from its connection's scheme is told in x-forwarded-proto the connection's under client_address connection, and under forwarded the x-forwarded-proto it arrived with, or the connection's when it arrived with none, where Envoy tells it the :scheme; under client_address forwarded, an x-forwarded-proto that is neither http nor https, such as ftp, is told as it arrived, where Envoy tells the connection's scheme"}, + Note: "under client_address forwarded, over HTTP/2 a request whose :scheme differs from its connection's scheme is told in x-forwarded-proto the x-forwarded-proto it arrived with, or the connection's when it arrived with none, where Envoy tells it the :scheme, and an x-forwarded-proto that is neither http nor https, such as ftp, is told as it arrived, where Envoy tells the connection's scheme"}, "auth.jwt": haproxyNoJWT, "auth.jwt.issuer": haproxyNoJWT, "auth.jwt.audiences": haproxyNoJWT, @@ -421,12 +427,16 @@ var haproxyTarget = Target{Name: "haproxy", Title: "HAProxy", Keys: map[string]S }, LessStrict: haproxyLessStrict} // haproxyLessStrict are the ways the HAProxy output is less strict than the Envoy output. HAProxy's parsers decide -// each but the last before any rule of the file reads the request, and its timeout counts the time without data, so -// the file can close none of them: the file refuses a control byte in a header value with a rule, but no fetch reads a -// request trailer, which option http-drop-request-trailers removes before the service. The last is the file's own: it +// each of the request line's before any rule of the file reads the request, and its timeout counts the time without +// data, so the file can close none of them: the file refuses a control byte in a header value with a rule, but no fetch +// reads a request trailer, which option http-drop-request-trailers removes before the service. The admin listener's +// is HAProxy's monitor-uri, which answers an absolute target by the path it names. The last is the file's own: it // keeps the X-Forwarded-Proto a request arrived with under forwarded, as the Envoy output keeps it for the service, and // tells the check that header. Each was measured on HAProxy 3.2.26 and 3.4.7 beside Envoy 1.40.2, the two images -// alike. +// alike. Two ways nginx's list names were measured on HAProxy too and do not hold, as docs/haproxy.md says: under +// client_address connection an absolute https target sent over plain HTTP is answered 400 and asks no check (the +// battery's row "an absolute https target with a token the check denies", on connection.yaml), and a tab at either end +// of a header value is removed before the service. var haproxyLessStrict = []LessStrict{ {Row: requestLine, Name: "an HTTP/2 :authority with a default or empty port reaches the service without it", Measured: "Over HTTP/2, `:authority: api.example.com:` and, over plain HTTP, `api.example.com:80` reach the service as `Host: api.example.com`, where the Envoy output sends them as written."}, @@ -446,6 +456,8 @@ var haproxyLessStrict = []LessStrict{ Measured: "A WebSocket upgrade a service answers `200` without switching reaches the client with the service's body, where Envoy passes the status and headers with no body."}, {Row: requestLine, Name: "a trailer value holding a control byte is served", Measured: "A request trailer value holding one of the bytes 0x01 to 0x08, 0x0B, 0x0C, 0x0E to 0x1F or 0x7F is served, the service receiving the body and no trailer, where Envoy answers `400` over HTTP/1.1 and closes the connection over HTTP/2. A header value holding one is answered `400` over HTTP/1.1, as by Envoy, and its stream is reset over HTTP/2, where Envoy closes the connection; HAProxy refuses 0x00, a line feed and a carriage return in either value, with `400` over HTTP/1.1 and a reset stream over HTTP/2."}, + {Row: "admin", Name: "the admin listener serves an absolute target of any scheme as the path it names", + Measured: "`GET http://localhost/ready HTTP/1.1` with `Host: localhost`, sent to the admin listener, is answered `200` with HAProxy's page `Service ready.`, and so is the same target with `https://`, `HTTP://`, `ftp://` or `ws://`, or with user information, `http://u@localhost/ready`, where the Envoy output's admin listener answers `404` with no body to every absolute target. `http://localhost/nothing` and `http://localhost/ready?x=1` are answered `404` by both, and a target whose host or port is not the Host header's, such as `http://other.example/ready` or `http://localhost:9901/ready`, `400`, where the Envoy output answers `404`."}, {Row: "timeouts.request", Name: "without timeouts.request, an answer that keeps arriving runs past 15 s", Measured: "Without `timeouts.request`, a service that keeps sending runs past 15 s, where the Envoy output ends a request 15 s after it starts: HAProxy's `timeout server` counts the time without data (on HAProxy 3.4.7, a service that sent one byte a second for 10 s under a 2 s `timeout server` was served)."}, // The battery's row "an x-forwarded-proto that is neither http nor https" holds it on two-checks. diff --git a/internal/format/support_nginx.go b/internal/format/support_nginx.go index 28b991e..6b96e67 100644 --- a/internal/format/support_nginx.go +++ b/internal/format/support_nginx.go @@ -333,7 +333,8 @@ var nginxTarget = Target{Name: "nginx", Title: "nginx", Keys: map[string]Support // s_client's, ECDHE-RSA-AES256-GCM-SHA384 where Envoy chose ECDHE-RSA-CHACHA20-POLY1305, and P-256 for an offer // that names it first, where Envoy chose X25519, or X25519MLKEM768 over TLS 1.3. With client certificates nginx // answers 421 to a request whose Host is another name than its TLS server name, when that name is an environment's - // host, even one of the same environment (measured on nginx 1.30.6 and 1.31.8 beside Envoy 1.40.2). + // host, even one of the same environment (measured on nginx 1.30.6 and 1.31.8 beside Envoy 1.40.2). The battery's + // row "plain HTTP sent to the TLS port", of mutual TLS, holds the 400. "tls": {Level: Partial, Note: "plain HTTP sent to the TLS port is answered 400, where the Envoy output closes the connection; from the same ciphers and key exchange groups nginx can choose others for the same client"}, "tls.certificate": {Level: Partial, Note: "a path without $", Refuses: []Refusal{nginxDollarPath}}, @@ -344,9 +345,12 @@ var nginxTarget = Target{Name: "nginx", Title: "nginx", Keys: map[string]Support // The Envoy output answers an X-Forwarded-Proto line with no colon 400, and nginx stores it as an empty value, // which the generator answers 404, as the Envoy output answers an empty one (measured on Envoy 1.40.2 beside nginx - // 1.30.6 and 1.31.8). + // 1.30.6 and 1.31.8). With connection the file appends $remote_addr whatever it is, where Envoy's connection + // manager appends its own local address for a peer on a loopback address (Envoy 1.40.2, conn_manager_utility.cc). + // The address the file sends is the client's, and the battery cannot send from a loopback address, so it was + // measured once, in a rig whose client ran in the proxy's network namespace. "client_address": {Level: Partial, - Note: "with forwarded, an X-Forwarded-Proto line with no colon is answered 404, where the Envoy output answers 400"}, + Note: "with forwarded, an X-Forwarded-Proto line with no colon is answered 404, where the Envoy output answers 400; with connection, a client on a loopback address is appended to X-Forwarded-For as that address, where the Envoy output appends its own address, as Envoy does for every loopback peer (measured with a client at 127.0.0.1 on nginx 1.30.6 and 1.31.8 beside Envoy 1.40.2)"}, "limits": {Level: Supported}, // nginx's own limit_conn (nginx.org, ngx_http_limit_conn_module): a connection counts only while it has a request in @@ -489,16 +493,16 @@ var nginxTarget = Target{Name: "nginx", Title: "nginx", Keys: map[string]Support // with no pattern route a path holding such a character is matched on $uri, which holds it decoded, and nginx // escapes it again only as it sends it to the service. nginx's $scheme is the connection's, and no variable holds // an HTTP/2 request's :scheme, so no line can tell the check one that differs (measured on nginx 1.30.6 and 1.31.8 - // beside Envoy 1.40.2, :scheme http over TLS and https without). Under client_address connection the file tells the - // check the connection's scheme over HTTP/1.1 too, whatever scheme an absolute target names, as a client writes the - // target: GET http://localhost/products/1 over TLS is told https, where the Envoy output tells http (the battery's - // row "an absolute target's host is the host the check is told", on nginx-auth and portable). Under forwarded the - // file tells the check the client's X-Forwarded-Proto as it arrived, the word a proxy in front writes, which the - // generator does not bound: X-Forwarded-Proto: ftp is told ftp, where the Envoy output tells the connection's - // scheme, and both send the service ftp (the battery's row "an x-forwarded-proto that is neither http nor https", - // on nginx-checks and nginx-tracing; the list of ways nginx is less strict names it). + // beside Envoy 1.40.2, :scheme http over TLS and https without). Under client_address connection the file and the + // Envoy output tell the check the connection's scheme, whatever an absolute target, an HTTP/2 :scheme or a + // client's X-Forwarded-Proto names (the battery's scenario of the scheme the check is told, on nginx-auth, + // portable and connection.yaml). Under forwarded the file tells the check the client's X-Forwarded-Proto as it + // arrived, the word a proxy in front writes, which the generator does not bound: X-Forwarded-Proto: ftp is told + // ftp, where the Envoy output tells the connection's scheme, and both send the service ftp (the battery's row "an + // x-forwarded-proto that is neither http nor https", on nginx-checks and nginx-tracing; the list of ways nginx is + // less strict names it). "auth.send_request": {Level: Partial, - Note: "in a file with no pattern route, a path holding a character Envoy escapes before it picks a route (\" < > ^ ` { | }) is told in x-forwarded-uri as the client wrote that character, where Envoy tells it escaped; the service receives it escaped from both; over HTTP/2 a request whose :scheme differs from its connection's scheme is told in x-forwarded-proto the connection's under client_address connection, and under forwarded the x-forwarded-proto it arrived with, or the connection's when it arrived with none, where Envoy tells it the :scheme; under client_address connection, so is an absolute target over HTTP/1.1 whose scheme differs from its connection's: an http target sent over TLS is told https, where Envoy tells it http; under client_address forwarded, an x-forwarded-proto that is neither http nor https, such as ftp, is told as it arrived, where Envoy tells the connection's scheme"}, + Note: "in a file with no pattern route, a path holding a character Envoy escapes before it picks a route (\" < > ^ ` { | }) is told in x-forwarded-uri as the client wrote that character, where Envoy tells it escaped; the service receives it escaped from both; under client_address forwarded, over HTTP/2 a request whose :scheme differs from its connection's scheme is told in x-forwarded-proto the x-forwarded-proto it arrived with, or the connection's when it arrived with none, where Envoy tells it the :scheme, and an x-forwarded-proto that is neither http nor https, such as ftp, is told as it arrived, where Envoy tells the connection's scheme"}, "auth.jwt": nginxNoJWT, "auth.jwt.issuer": nginxNoJWT, "auth.jwt.audiences": nginxNoJWT, @@ -776,7 +780,8 @@ var nginxLessStrict = []LessStrict{ Measured: "`GET http://localhost/ready HTTP/1.1` sent to the admin listener is answered `200` with `LIVE`, and so is the same target with `https://` or `HTTP://`, and `http://localhost/stats` and `http://localhost/server_info` are answered `200` with nginx's counters and its version, where the Envoy output's admin listener answers `404` with no body to every absolute target. A path the admin listener does not answer, `http://localhost/nothing`, is answered `404` by both, and a target of another scheme, `ftp://localhost/ready` or `ws://localhost/ready`, `400` with the body `Bad Request` and the connection closed, where the Envoy output answers `404`."}, // Measured with the Envoy output of client_address: connection, which writes use_remote_address: true, and of // forwarded, which writes false; the request checks of the nginx output take an absolute http and https target alike. - // The battery's row "an absolute https target", of the scheme the check is told, holds it on nginx-connection. + // The battery's rows "an absolute https target" and "an absolute HTTPS target in capitals", of the scheme the check + // is told, hold it on connection.yaml. {Row: "client_address", Name: "under connection, an absolute https target sent over plain HTTP is served", Measured: "With `client_address: connection` and no `tls`, an absolute `https` target sent over plain HTTP, such as `GET https://localhost/products/1 HTTP/1.1`, or the same with `HTTPS://`, is served: the service receives `X-Forwarded-Proto: http`, and with `auth.send_request: true` the check is told `x-forwarded-proto: http`, the connection's scheme, where the Envoy output answers `403` with the body `Forbidden`, writes `http1.https_url_on_plaintext_connection` in its request log, closes the connection and asks no check. Under `forwarded` both serve it, and the service receives `x-forwarded-proto: http` through both."}, {Row: "timeouts.request", Name: "without timeouts.request, an answer that keeps arriving runs past 15 s", diff --git a/internal/format/support_test.go b/internal/format/support_test.go index d0d373c..5d0538d 100644 --- a/internal/format/support_test.go +++ b/internal/format/support_test.go @@ -685,7 +685,7 @@ func TestLessStrictWarning(t *testing.T) { for _, c := range []struct{ target, want string }{ {"envoy", ""}, {"nginx", `this nginx configuration is less strict than the Envoy output in 19 ways; docs/nginx.md lists them under "Where nginx is less strict than the Envoy output"`}, - {"haproxy", `this HAProxy configuration is less strict than the Envoy output in 11 ways; docs/haproxy.md lists them under "Where HAProxy is less strict than the Envoy output"`}, + {"haproxy", `this HAProxy configuration is less strict than the Envoy output in 12 ways; docs/haproxy.md lists them under "Where HAProxy is less strict than the Envoy output"`}, } { target, _ := TargetNamed(c.target) if got := LessStrictWarning(target); got != c.want { @@ -704,6 +704,32 @@ func TestLessStrictList(t *testing.T) { } } +// A page's list of notes gives each row's note in the declaration's words, escaped as the support table escapes them, +// then each form the target refuses in the words render prints; rows side by side with the same declaration share one +// item, and a row written with no key is named by its words. A row the target does not declare partial has no note. +func TestNoteList(t *testing.T) { + const noKey = "a dot segment with a ; parameter answered 400" + target := Target{Name: "lean", Title: "Lean", Keys: map[string]Support{ + "a.b": {Level: Partial, Note: "x_y is *served*"}, + "a.c": {Level: Partial, Note: "x_y is *served*"}, + "d": {Level: Partial, Note: "z", Refuses: []Refusal{{Form: "of 2 or more", Instead: "write 1"}, + {Form: "naming e", Instead: "remove it"}}}, + noKey: {Level: Partial, Note: "w"}, + "e": {Level: Supported}, + }} + want := "- **`a.b` and `a.c`**: x\\_y is \\*served\\*.\n" + + "- **`d`**: z. \"d\" of 2 or more is refused by --target lean: write 1. \"d\" naming e is refused by --target lean: remove it.\n" + + "- **a dot segment with a ; parameter answered 400**: w.\n" + got, err := NoteList(target, []string{"a.b", "a.c", "d", noKey}) + if string(got) != want || err != nil { + t.Errorf("NoteList = %q, %v\nwant %q, nil", got, err, want) + } + if got, err := NoteList(target, []string{"a.b", "e"}); got != nil || err == nil || + err.Error() != `a list of notes names "e", which lean does not declare partial` { + t.Errorf("NoteList with a supported row = %q, %v, want nil and the error naming the row", got, err) + } +} + // HAProxy and nginx name the ways their pages list, each on the row the support table gives it. func TestLessStrictWays(t *testing.T) { const line = "the request line and header names read before a route is picked" @@ -722,6 +748,7 @@ func TestLessStrictWays(t *testing.T) { {line, "over HTTP/2, two host fields and no :authority are served"}, {line, "a WebSocket upgrade a service answers without switching passes the service's body"}, {line, "a trailer value holding a control byte is served"}, + {"admin", "the admin listener serves an absolute target of any scheme as the path it names"}, {"timeouts.request", "without timeouts.request, an answer that keeps arriving runs past 15 s"}, {"auth.send_request", "under forwarded, an x-forwarded-proto that is neither http nor https is told to the check as it arrived"}, }}, @@ -784,14 +811,14 @@ func TestHAProxyWrites(t *testing.T) { } wantWritten := []declared{ {key: "listen", level: Supported}, - {key: "admin", level: Partial, note: "/ready answers 200 while HAProxy runs, not when the server is ready; no other admin path in this version"}, + {key: "admin", level: Partial, note: "/ready answers 200 while HAProxy runs, not when the server is ready; no other admin path in this version; an absolute target whose host or port is not the Host header's is answered 400, where the Envoy output answers 404"}, {key: "tls", level: Partial, note: "of the TLS 1.2 suites both take, HAProxy picks by its own order, where Envoy takes the client's among suites it holds equal: a client that offers OpenSSL's default list is given ECDHE-RSA-AES128-GCM-SHA256, where Envoy gives ECDHE-RSA-CHACHA20-POLY1305"}, {key: "tls.certificate", level: Supported}, {key: "tls.key", level: Supported}, {key: "tls.clients", level: Supported}, {key: "tls.clients.ca", level: Partial, note: "a client certificate that is not valid yet is refused with the alert bad_certificate, where Envoy sends certificate_expired"}, {key: "client_address", level: Partial, - note: "under forwarded, a client's own X-Request-Id longer than 980 bytes, or than 908 bytes less an echoed Origin and cors.expose_headers, is answered 400 before the check and the service, where the Envoy output serves it: HAProxy echoes the id in the 1,024 bytes it keeps for the lines it adds to an answer; over HTTP/2 an X-Forwarded-Proto of spaces alone is answered 404, where the Envoy output serves it"}, + note: "under forwarded, a client's own X-Request-Id longer than 980 bytes, or than 908 bytes less an echoed Origin and cors.expose_headers, is answered 400 before the check and the service, where the Envoy output serves it: HAProxy echoes the id in the 1,024 bytes it keeps for the lines it adds to an answer; over HTTP/2 an X-Forwarded-Proto of spaces alone is answered 404, where the Envoy output serves it; under connection, a client on a loopback address is appended to X-Forwarded-For as that address, where the Envoy output appends its own address, as Envoy does for every loopback peer (measured with a client at 127.0.0.1 on HAProxy 3.2.26 and 3.4.7 beside Envoy 1.40.2)"}, {key: "limits", level: Supported}, {key: "limits.connections", level: Partial, note: "HAProxy's own maxconn on the listener and on each server: a connection past it waits in the listen queue, and a request past a server's waits up to 5 s in HAProxy's queue and is then answered 503; the limit to a service counts on each of its addresses"}, @@ -857,7 +884,7 @@ func TestHAProxyWrites(t *testing.T) { refuses: "naming content-length, transfer-encoding, host, te, connection or upgrade in full: HAProxy frames or routes a request by these headers, so the check's answer never sets them; remove the name from auth.accept" + "; " + "holding a * prefix that covers content-length, connection or upgrade: the Envoy output sends the body chunked once Content-Length is removed, and leaves a WebSocket upgrade unanswered once Connection or Upgrade is removed, which HAProxy cannot write; write the other names in full, or a longer prefix, or render it for envoy"}, {key: "auth.send_request", level: Partial, - note: "over HTTP/2 a request whose :scheme differs from its connection's scheme is told in x-forwarded-proto the connection's under client_address connection, and under forwarded the x-forwarded-proto it arrived with, or the connection's when it arrived with none, where Envoy tells it the :scheme; under client_address forwarded, an x-forwarded-proto that is neither http nor https, such as ftp, is told as it arrived, where Envoy tells the connection's scheme"}, + note: "under client_address forwarded, over HTTP/2 a request whose :scheme differs from its connection's scheme is told in x-forwarded-proto the x-forwarded-proto it arrived with, or the connection's when it arrived with none, where Envoy tells it the :scheme, and an x-forwarded-proto that is neither http nor https, such as ftp, is told as it arrived, where Envoy tells the connection's scheme"}, {key: "remove_from_clients", level: Partial, note: "names and * prefixes that cover none of content-length, connection and upgrade", refuses: "holding content-length, connection or upgrade, in full or under a * prefix: the Envoy output sends the body chunked once Content-Length is removed, and leaves a WebSocket upgrade unanswered once Connection or Upgrade is removed, which HAProxy cannot write; write the other names in full, or a longer prefix, or render it for envoy"}, {key: "cors", level: Supported}, diff --git a/internal/haproxy/haproxy.cfg.tmpl b/internal/haproxy/haproxy.cfg.tmpl index 01a2ec0..e6caac7 100644 --- a/internal/haproxy/haproxy.cfg.tmpl +++ b/internal/haproxy/haproxy.cfg.tmpl @@ -213,7 +213,8 @@ frontend public {{- if .Connection}} {{- /* Envoy takes the client for one it faces: it removes what only a proxy in front may send, appends the peer's address to the client's own X-Forwarded-For on the same line, or writes it alone when the client sent none or an - empty one, and replaces x-envoy-external-address and x-forwarded-proto (measured). */}} + empty one, and replaces x-envoy-external-address and x-forwarded-proto (measured). For a peer on a loopback address + Envoy appends its own address, which this file does not copy (the client_address note). */}} {{- range .Faced}} http-request del-header {{.}} {{- end}} diff --git a/internal/nginx/auth.go b/internal/nginx/auth.go index 7e1837a..aadb540 100644 --- a/internal/nginx/auth.go +++ b/internal/nginx/auth.go @@ -128,15 +128,15 @@ func checkLines(in generator.Input, v *values, e edge) (http, stream []string) { http = append(http, ` map "" $pf_counted_address { default `+address+"; }") if a.SendRequest { // The Envoy output tells the check the path its route matched, normalised as the route sends it, before a - // rewrite, with the query as the client wrote it, and the scheme of a target written with one, in any letter - // case, over the connection's or the client's X-Forwarded-Proto (measured on Envoy 1.40.2). Inside the - // subrequest $request_uri and $request are the client's and $pf_path keeps the value the route choice read; the - // query comes from $request_uri, as $args is the subrequest's. + // rewrite, with the query as the client wrote it, and, under forwarded, the scheme of a target written with + // one, in any letter case, over the connection's or the client's X-Forwarded-Proto (measured on Envoy 1.40.2). + // Inside the subrequest $request_uri and $request are the client's and $pf_path keeps the value the route + // choice read; the query comes from $request_uri, as $args is the subrequest's. // With connection the client that writes the target is not trusted for its scheme, so the check is told the // connection's, the one the service is sent, as docs/auth.md says: the target's would tell it https for an // https target sent over plain HTTP, which nginx serves and the Envoy output answers 403 (measured on nginx - // 1.30.6 and 1.31.8 beside Envoy 1.40.2). Over TLS an http target is then told https, where the Envoy output - // tells http, as an HTTP/2 :scheme is (the auth.send_request row). + // 1.30.6 and 1.31.8 beside Envoy 1.40.2). Over TLS an http target is then told https, as by the Envoy output, + // which under connection writes the listener's scheme as text (filter-ext-authz.yaml). toldProto := ` map $request $pf_told_proto { ` + quoted(`~*^[^ ]+ +https://`) + ` https; ` + quoted(`~*^[^ ]+ +http://`) + ` http; default $pf_forwarded_proto; }` if e.connection { diff --git a/internal/nginx/generate.go b/internal/nginx/generate.go index 1f53570..8ebbd37 100644 --- a/internal/nginx/generate.go +++ b/internal/nginx/generate.go @@ -169,7 +169,8 @@ func newRequestID() []string { // writeForwardingMaps writes the values the routes send as X-Request-Id, X-Forwarded-Proto and, with client_address // connection, X-Forwarded-For. With connection the Envoy output makes a new request id whatever the client sent, sends -// the connection's scheme, and appends the peer's address to the client's X-Forwarded-For with a comma and no space; +// the connection's scheme, and appends the peer's address to the client's X-Forwarded-For with a comma and no space, +// its own address for a peer on a loopback address, which this file does not copy (the client_address note); // with forwarded it keeps the client's id and scheme when it sent them, and sends X-Forwarded-For as received, which // nginx does with no line (measured on Envoy 1.40.2). A header remove_from_clients removes reads as empty. func writeForwardingMaps(w *writer, e edge) { diff --git a/internal/nginx/generate_test.go b/internal/nginx/generate_test.go index adeea80..0fe2697 100644 --- a/internal/nginx/generate_test.go +++ b/internal/nginx/generate_test.go @@ -697,8 +697,9 @@ func TestSecurityLines(t *testing.T) { }}, {"connection: the address is the peer's", func() string { // The Envoy output with client_address connection makes a new request id, sends the connection's scheme, - // appends the peer's address to the client's X-Forwarded-For and sends it as x-envoy-external-address, and - // removes five more x-envoy- headers; with X-Forwarded-For removed it sends the peer's address alone. + // appends the peer's address to the client's X-Forwarded-For, its own for a peer on a loopback address, which + // nginx does not copy, sends the peer's as x-envoy-external-address, and removes five more x-envoy- headers; + // with X-Forwarded-For removed it sends the peer's address alone. for _, want := range []struct{ out, line string }{ {out, ` map "" $pf_request_id { default $pf_new_request_id; }`}, {out, ` map "" $pf_forwarded_proto { default $scheme; }`}, diff --git a/internal/render/render_test.go b/internal/render/render_test.go index a205e29..871c17c 100644 --- a/internal/render/render_test.go +++ b/internal/render/render_test.go @@ -1549,6 +1549,27 @@ typed_config: headers_to_add: [{key: x-gateway-timeout-ms, value: "1000"}, {key: x-forwarded-uri, value: "%REQ(:PATH)%"}, {key: x-forwarded-method, value: "%REQ(:METHOD)%"}, {key: x-forwarded-proto, value: "%REQ(:SCHEME)%"}, {key: x-forwarded-host, value: "%REQ(:AUTHORITY)%"}] +`}, + // Under client_address connection the check is told the scheme of the connection, which the listener's tls + // decides, whatever the client writes in the request line, an HTTP/2 :scheme or its own X-Forwarded-Proto + // (measured on Envoy 1.40.2, where %REQ(:SCHEME)% told the check an HTTP/2 :scheme https sent over plain HTTP). + {name: "send_request under connection without tls, what the check is told", proxyfile: askWithRequest + "client_address: connection\n", + at: slices.Concat(manager, []any{"http_filters", 4, "typed_config", "http_service", "authorization_request"}), want: ` +headers_to_add: [{key: x-gateway-timeout-ms, value: "1000"}, {key: x-forwarded-uri, value: "%REQ(:PATH)%"}, + {key: x-forwarded-method, value: "%REQ(:METHOD)%"}, {key: x-forwarded-proto, value: http}, + {key: x-forwarded-host, value: "%REQ(:AUTHORITY)%"}] +`}, + {name: "send_request under connection with tls, what the check is told", proxyfile: askWithRequest + "tls: {certificate: /c.pem, key: /k.pem}\n", + at: slices.Concat(manager, []any{"http_filters", 4, "typed_config", "http_service", "authorization_request"}), want: ` +headers_to_add: [{key: x-gateway-timeout-ms, value: "1000"}, {key: x-forwarded-uri, value: "%REQ(:PATH)%"}, + {key: x-forwarded-method, value: "%REQ(:METHOD)%"}, {key: x-forwarded-proto, value: https}, + {key: x-forwarded-host, value: "%REQ(:AUTHORITY)%"}] +`}, + {name: "send_request under forwarded with tls, what the check is told", proxyfile: askWithRequest + "tls: {certificate: /c.pem, key: /k.pem}\nclient_address: forwarded\n", + at: slices.Concat(manager, []any{"http_filters", 4, "typed_config", "http_service", "authorization_request"}), want: ` +headers_to_add: [{key: x-gateway-timeout-ms, value: "1000"}, {key: x-forwarded-uri, value: "%REQ(:PATH)%"}, + {key: x-forwarded-method, value: "%REQ(:METHOD)%"}, {key: x-forwarded-proto, value: "%REQ(:SCHEME)%"}, + {key: x-forwarded-host, value: "%REQ(:AUTHORITY)%"}] `}, {name: "send_request, the path normalised", proxyfile: askWithRequest, at: slices.Concat(manager, []any{"normalize_path"}), want: "true"}, {name: "send_request, the slashes merged", proxyfile: askWithRequest, at: slices.Concat(manager, []any{"merge_slashes"}), want: "true"}, diff --git a/internal/render/testdata/full.expected.yaml b/internal/render/testdata/full.expected.yaml index c2ee6f3..03cdfb0 100644 --- a/internal/render/testdata/full.expected.yaml +++ b/internal/render/testdata/full.expected.yaml @@ -237,7 +237,7 @@ static_resources: server_uri: {uri: "http://127.0.0.1:7070/auth/check", cluster: "accounts_http", timeout: 1.5s} path_override: "/auth/check" authorization_request: - headers_to_add: [{key: x-gateway-timeout-ms, value: "1500"}, {key: x-forwarded-uri, value: "%REQ(:PATH)%"}, {key: x-forwarded-method, value: "%REQ(:METHOD)%"}, {key: x-forwarded-proto, value: "%REQ(:SCHEME)%"}, {key: x-forwarded-host, value: "%REQ(:AUTHORITY)%"}] + headers_to_add: [{key: x-gateway-timeout-ms, value: "1500"}, {key: x-forwarded-uri, value: "%REQ(:PATH)%"}, {key: x-forwarded-method, value: "%REQ(:METHOD)%"}, {key: x-forwarded-proto, value: "https"}, {key: x-forwarded-host, value: "%REQ(:AUTHORITY)%"}] authorization_response: allowed_upstream_headers: patterns: