Skip to main content
Notice removed Draw attention by CommunityBot
Bounty Ended with no winning answer by CommunityBot
Notice added Draw attention by GreatBlakes
Bounty Started worth 50 reputation by GreatBlakes
Tweeted twitter.com/StackWebmasters/status/1287538269392117761
title clarity
Link
Stephen Ostermiller
  • 99.4k
  • 18
  • 141
  • 364

HTTP2 is enabled and working, but PHP is$_SERVER['SERVER_PROTOCOL'] still sayingsays "HTTP/1.1"

Source Link
GreatBlakes
  • 545
  • 3
  • 16

HTTP2 is enabled and working, but PHP is still saying "HTTP/1.1"

I've been migrating to a new host (AWS Lightsail with a Ubuntu instance) and while everything is working just fine I'm running into a quirk that I can't quite figure out.

I've enabled HTTP2 on my virtual server and confirmed that files are using that protocol (via DevTools and http2.pro):

HTTP2 working in DevTools

HTTP2 working per http2.pro

For reference, here is my server showing the Apache HTTP2 mod is enabled (and I did restart apache afterwords)

http2 mod already enabled

However, in PHP when I output $_SERVER['SERVER_PROTOCOL'] on my server it is still showing "HTTP/1.1":

http1.1

php code

But this same exact software (WordPress theme) on other servers is showing "HTTP/2.0" correctly:

http2 detected with same exact code

I believe I have my Apache2 conf files setup correctly:

Port 443:

<VirtualHost *:443>
    Protocols h2 h2c http/1.1

and just to be thorough I did Port 80 as well:

<VirtualHost *:80>
    Protocols h2 h2c http/1.1

Unfortunately I do not have access to the conf files (or ssh) on the server that is working, so I can't cross-reference those files.

I've been reading a bunch of tutorials on HTTP2 to see if there is any additional setting or configuration that I may have missed, but most are showing the same instructions that I've implemented.

Can anyone point me in the right direction as to why this PHP "detection" is incorrectly displaying the protocol, or if there is something I missed that is preventing PHP from using HTTP2 in this one situation?