0

Using homemade proxy software that adds/removes headers as specified (yes, I violate proxy standards), I add Content-Encoding: br to a file in Brotli format served by the upstream:

docker run --net=host --rm proxy /root/proxy/target/release/proxy --port 8080 http://localhost:1633 \
    -A "Content-Encoding: br" -R "Accept-Ranges" -R "Content-Length" -R "Decompressed-Content-Length"

(-A flags add headers, -R flags remove headers).

Then I add yet one proxy level, Apache (with the purpose to add SSL):

ProxyPass "/" "http://localhost:8080/bzz/"

A request https://test.vporton.name/008e1e5b3e2f4f2cf04a48e49c2fdafeac6e9a01f0159c6881812e919f4f8476/index.html to Apache returns:

< HTTP/1.1 200 OK
< Date: Sun, 05 Jun 2022 03:43:53 GMT
< Server: Apache/2.4.52 (Ubuntu)
< content-encoding: br
< x-forwarded-server: test.vporton.name
< user-agent: curl/7.81.0
< x-forwarded-host: test.vporton.name
< accept: */*
< host: localhost:8080
< x-forwarded-for: 87.71.212.18
< Transfer-Encoding: chunked
< Content-Type: text/html

When I try to open it in a browser, it (for Firefox) tells about bad page encoding or (for Chrome) shows empty page. Why did I do wrong? (Clearing cache and restarting the browser does not work.)

I am sure that file is correctly encoded as Brotli:

curl https://test.vporton.name/008e1e5b3e2f4f2cf04a48e49c2fdafeac6e9a01f0159c6881812e919f4f8476/index.html | brotli --test

returns no error. Moreover,

curl https://test.vporton.name/008e1e5b3e2f4f2cf04a48e49c2fdafeac6e9a01f0159c6881812e919f4f8476/index.html | brotli --decompress

produces a HTML file as intended.

porton
  • 5,214
  • 11
  • 47
  • 95

0 Answers0