[英]Does nginx support early hint request (103 status)
I have used nginx as a reverse proxy with puma server.我使用 nginx 作为 puma 服务器的反向代理。
I am sending 103 status response from the puma for early hint about assets that would be needed.我正在发送来自美洲狮的 103 状态响应,以获取有关所需资产的早期提示。
When I load the page in chrome, it shows me ERR_SPDY_PROTOCOL_ERROR error.当我在 chrome 中加载页面时,它显示 ERR_SPDY_PROTOCOL_ERROR 错误。 It works fine on Firefox.
它在 Firefox 上运行良好。 Not working on safari as well.
也不在 safari 上工作。
It works fine in chrome only if I stop sending 103 status response from puma.只有当我停止从 puma 发送 103 状态响应时,它才能在 Chrome 中正常工作。
Below is my nginx.config file下面是我的 nginx.config 文件
http {
upstream app {
server unix:/Users/rohan/puma.sock fail_timeout=0;
}
server {
listen 443 ssl http2;
server_name localhost;
ssl_certificate /usr/Users/rohan/localhost.crt;
ssl_certificate_key /Users/rohan/localhost.key;
root /Users/rohan/test_app/my_app/public;
try_files $uri/index.html $uri @app;
access_log /Users/rohan/nginx.access.log;
location @app {
proxy_pass http://app;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
http2_push_preload on;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
}
Below is output from nghttp client下面是 nghttp 客户端的输出
Rohans-MacBook: rohan$ nghttp -nv https://127.0.0.1/students
[ 0.010] Connected
[WARNING] Certificate verification failed: Hostname mismatch
The negotiated protocol: h2
[ 0.013] recv SETTINGS frame <length=18, flags=0x00, stream_id=0>
(niv=3)
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):128]
[SETTINGS_INITIAL_WINDOW_SIZE(0x04):65536]
[SETTINGS_MAX_FRAME_SIZE(0x05):16777215]
[ 0.013] recv WINDOW_UPDATE frame <length=4, flags=0x00, stream_id=0>
(window_size_increment=2147418112)
[ 0.013] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
(niv=2)
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
[SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[ 0.013] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
; ACK
(niv=0)
[ 0.013] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
(dep_stream_id=0, weight=201, exclusive=0)
[ 0.013] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
(dep_stream_id=0, weight=101, exclusive=0)
[ 0.013] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
(dep_stream_id=0, weight=1, exclusive=0)
[ 0.013] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
(dep_stream_id=7, weight=1, exclusive=0)
[ 0.013] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
(dep_stream_id=3, weight=1, exclusive=0)
[ 0.013] send HEADERS frame <length=43, flags=0x25, stream_id=13>
; END_STREAM | END_HEADERS | PRIORITY
(padlen=0, dep_stream_id=11, weight=16, exclusive=0)
; Open new stream
:method: GET
:path: /students
:scheme: https
:authority: 127.0.0.1
accept: */*
accept-encoding: gzip, deflate
user-agent: nghttp2/1.32.0
[ 0.014] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
; ACK
(niv=0)
[ 0.071] recv (stream_id=13) :method: GET
[ 0.071] recv (stream_id=13) :path: /assets/application.self-f0d704deea029cf000697e2c0181ec173a1b474645466ed843eb5ee7bb215794.css
[ 0.071] recv (stream_id=13) :scheme: https
[ 0.071] recv (stream_id=13) :authority: 127.0.0.1
[ 0.071] recv (stream_id=13) accept-encoding: gzip, deflate
[ 0.071] recv (stream_id=13) user-agent: nghttp2/1.32.0
[ 0.071] recv PUSH_PROMISE frame <length=106, flags=0x04, stream_id=13>
; END_HEADERS
(padlen=0, promised_stream_id=2)
[ 0.071] recv (stream_id=13) :status: 103
[ 0.071] recv (stream_id=13) server: nginx/1.13.12
[ 0.071] recv (stream_id=13) date: Wed, 30 May 2018 18:15:58 GMT
[ 0.071] recv (stream_id=13) link: </assets/application.self-f0d704deea029cf000697e2c0181ec173a1b474645466ed843eb5ee7bb215794.css>; rel=preload; as=style
[ 0.071] recv HEADERS frame <length=132, flags=0x04, stream_id=13>
; END_HEADERS
(padlen=0)
; First response header
[ 0.071] recv (stream_id=2) :status: 200
[ 0.071] recv (stream_id=2) server: nginx/1.13.12
[ 0.071] recv (stream_id=2) date: Wed, 30 May 2018 18:15:58 GMT
[ 0.071] recv (stream_id=2) content-type: text/css; charset=utf-8
[ 0.071] recv (stream_id=2) content-length: 676
[ 0.071] recv (stream_id=2) cache-control: public, max-age=31536000
[ 0.071] recv (stream_id=2) etag: "f0d704deea029cf000697e2c0181ec173a1b474645466ed843eb5ee7bb215794"
[ 0.071] recv (stream_id=2) x-request-id: a7bd5757-b7ab-4d7a-9c48-10b5133fe11e
[ 0.071] recv (stream_id=2) x-runtime: 0.010249
[ 0.071] recv HEADERS frame <length=198, flags=0x04, stream_id=2>
; END_HEADERS
(padlen=0)
; First push response header
[ 0.071] recv DATA frame <length=676, flags=0x01, stream_id=2>
; END_STREAM
[ 0.080] send RST_STREAM frame <length=4, flags=0x00, stream_id=13>
(error_code=PROTOCOL_ERROR(0x01))
[ 0.080] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
(last_stream_id=2, error_code=NO_ERROR(0x00), opaque_data(0)=[])
Some requests were not processed. total=2, processed=1
Is Early hint supported by nginx? nginx 支持早期提示吗? I am not able to get any documentation stating that it supports it.
我无法获得任何说明它支持它的文档。 But I assummed it as it supports HTTP/2.
但我假设它支持 HTTP/2。
From the discussion https://github.com/puma/puma/issues/1570来自讨论https://github.com/puma/puma/issues/1570
If you need a server implementing early hints, you can use https://h2o.examp1e.net如果您需要一个实现早期提示的服务器,您可以使用https://h2o.examp1e.net
I'm yet to use it but H2O works quite good and production ready once everything is working.我还没有使用它,但 H2O 工作得很好,一旦一切正常,生产准备就绪。
如果你想使用Nginx 的 http2_push_preload 功能,你也可以使用early_hints_header gem
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.