Мне интересно, можно ли использовать функцию HTTP / 2 Server Push за HAProxy. HAProxy 2. + поддерживает HTTP / 2 во внешнем и внутреннем интерфейсе. Я создал простую настройку для тестирования, насколько я могу судить, веб-сервер Apache не отправляет контент, если он находится за HAProxy. Для тестирования я использовал клиент nghttp.
Конфигурация HAProxy 2.1 Backend
backend test-http2-push
server localhost 127.0.0.1:81 proto h2 check
Конфигурация HTTP / 2 Apache 2.4.38
H2Push on
H2EarlyHints on
Protocols h2c h2 http/1.1
Header set Link "</push1.css>; rel=preload; as=style"
H2PushResource /push2 critical
Прямой запрос бэкэнда Apache
nghttp -ans http://test-http2-push.development.vm:81
ответ
***** Statistics *****
Request timing:
responseEnd: the time when last byte of response was received
relative to connectEnd
requestStart: the time just before first byte of request was sent
relative to connectEnd. If '*' is shown, this was
pushed by server.
process: responseEnd - requestStart
code: HTTP status code
size: number of bytes received as response body without
inflation.
URI: request URI
see http://www.w3.org/TR/resource-timing/#processing-model
sorted by 'complete'
id responseEnd requestStart process code size request path
13 +2.07ms +107us 1.96ms 200 2K /
2 +2.30ms * +1.70ms 594us 200 114 /push2.css
4 +2.31ms * +1.73ms 574us 200 114 /push1.css
Звездочкой отмечено нажатие на сервер.
Запрос HAProxy:
nghttp -ans https://test-http2-push.development.vm
ответ
***** Statistics *****
Request timing:
responseEnd: the time when last byte of response was received
relative to connectEnd
requestStart: the time just before first byte of request was sent
relative to connectEnd. If '*' is shown, this was
pushed by server.
process: responseEnd - requestStart
code: HTTP status code
size: number of bytes received as response body without
inflation.
URI: request URI
see http://www.w3.org/TR/resource-timing/#processing-model
sorted by 'complete'
id responseEnd requestStart process code size request path
13 +2.07ms +138us 1.93ms 200 2K /
19 +10.36ms +2.09ms 8.27ms 200 114 /push1.css
21 +10.92ms +2.09ms 8.83ms 200 114 /push2.css
Нет сервера.
Журнал Apache показывает, что HAProxy говорит HTTP / 2 с серверной частью:
127.0.0.1 - - [25/Mar/2020:18:26:52 +0100] "GET /push1.css HTTP/2.0" 200 114 192.168.56.1 forwarded by: 127.0.0.1
127.0.0.1 - - [25/Mar/2020:18:26:52 +0100] "GET /push2.css HTTP/2.0" 200 114 192.168.56.1 forwarded by: 127.0.0.1
Я что-то упускаю? Я ценю любую помощь.