I installed HTTP/2 on a local Apache server, running on Ubuntu.
HTTP/2 is working, as it manages to upgrade the protocol when I do CURL on a page:
$ /usr/bin/curl -I --http2 http://test.local/public/
/usr/bin/curl: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/curl)
HTTP/1.1 101 Switching Protocols
Upgrade: h2c
Connection: Upgrade
HTTP/2 200
...
Accessing the page from the browser, it still seems to be served as HTTP/1.1:
I would like HTTP/2 to work when served through the browser.
What am I missing here?
I’ve tried restarting my computer and Chromium, Chrome, FireFox and Brave without seeing it in HTTP/2. I’ve tried on WP, Symfony apps and simple HTML/CSS pages.
2
Answers
It turns out the browser requires HTTPS / SSL for HTTP/2 to work, while CURL doesn't.
Once I installed a local certificate and served the page over HTTPS, I got HTTP/2 in the browser and with CURL.
See: Why do browser implementations of HTTP/2 require TLS?
You are connecting over http:// and not https://.
Browsers only support HTTP/2 over https in part for compatibility reasons. See here for a fuller answer: Why do web browsers not support h2c (HTTP/2 without TLS)?