Force HTTP/2 With Chrome or Safari
Asked Answered
P

2

12

Is there some way to tell Chrome or Safari to use HTTP/2 on a specific URL/adress/server?

I mean by changing some setting or such, not by implementing ALPN on the server socket or whatever might be needed. I want to try HTTP/2 on a server socket without waiting till I can have ALPN negotiation to tell the browsers to use HTTP/2.


Clarification: I have HTTP/2 enabled on Chrome (aka SPDY/4 via chrome://flags). It still doesn't probe my (TLS or plaintext) socket for HTTP/2 via Upgrade. I want to force Chrome to either do this, or assume HTTP/2 right off the bat.

Also, I've read that Chrome won't support HTTP/2 over plaintext connections, even though the HTTP/2 standard allows it. But maybe there's some way around that.

Palmitate answered 1/4, 2015 at 19:58 Comment(0)
W
12

HTTP/2 over TLS and HTTP/2 over TCP have been defined as 2 different protocols, identified respectively by h2 and h2c.

Chrome supports h2 only at this time.

If you have a server that implements only h2c, the easiest way to connect Chrome to it is to use a reverse proxy such a nghttpx in HTTP/2 bridge mode in front of your server

Whoa answered 2/4, 2015 at 11:20 Comment(7)
Thanks for your answer. But: I want to try HTTP/2 on a server socket without waiting till I can have ALPN negotiation to tell the browsers to use HTTP/2.Palmitate
You don't have to "wait" for ALPN and it doesn't cost you anything more than a regular TLS handshake : instead of selecting simply the TLS protocol version, the server selects both the TLS protocol and the application protocol (ex. the browser announces support for TLS 1.1, TLS 1.2, HTTP/1.1, SDPY/3.1, H2, the server selects TLS 1.2 and H2 for the session. HTTP/2 on a cleartext socket is called h2c and is not supported by chrome.Whoa
What I mean by 'wait' is this: the 'platform' I use, Java, does not currently have TLS socket ALPN, but eventually, it will (can't imagine it not getting it at some point). By convincing the browser to use HTTP/2 directly, I would not need ALPN. Cf https://mcmap.net/q/1010689/-java-http-2-server-socketPalmitate
ALPN works fine with Java using the Jetty ALPN library. If you can't or don't want to use this library the easiest way is then to use nghttpx (nghttp2.org/documentation/nghttpx-howto.html) as a reverse proxy in front of your server. You can use HTTP/2 bridge mode to let nghttpx negociate HTTP/2 over TLS with the browser and use direct h2c on the backend to your java server.Whoa
Thanks for both ideas. The proxy idea is a good answer to this question, since it's still HTTP2 all the way, avoiding the head-of-line problem with HTTP1 that I need to avoid, so if you put it first in your answer text, I'll check it. The Jetty ALPN thing is a good answer for my Java question, I think.Palmitate
I've modified to answer to propose reverse proxy and will add ALPN Jetty to the Java questionWhoa
"HTTP/2 over TLS and HTTP/2 over TCP" could be changed, it's all TCP, right... anyway, accepted because proxying is the solution that doesn't require implementing ALPN on the server, even though it doesn't technically force a browser to use HTTP2. Maybe that is not going to happen. Browsers should at least do Upgrade on localhost, to help lazy server developers, that's my local stupid opinion at least. -- Thanks for playing!Palmitate
M
-1

As far as I know this is most likely a browser-wide setting. In chrome you can enable SPDY4, see chrome://flags

As far as safari goes support has been added since version 8.

In the end it's all about the knowing whether or not you speak the same language as the server. If you are using http you can check this by using the Upgrade header. There are some plugins out there you can use with chrome to give you an indication of whether or not the address your visiting supports http/2.

For more info on the http/2 protocol itself you should check out https://http2.github.io/http2-spec/#starting

Meant answered 1/4, 2015 at 20:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.