HTTP/2, yes or no?

I tried http/2 too, but I didn’t get much improvement. Sometimes the menu failed to load some pictures.

Here did some guy a deeper test and came to a similar result than here:

so no “performance for free” here

1 Like

I found the hint about http/2 in the new admin manuel here and also enabled it for my server by:

$ a2enmod http2

And adding:

<IfModule http2_module>
  ProtocolsHonorOrder On
  Protocols h2 http/1.1
</IfModule>

to my vhosts.

I got the quick guide from here.

Different checks by browser and testing websites confirm that everything is working fine so far. But I have some questions:

  • I have two vhosts, one for http requests over port 80 and one for https requests over port 443. Just the standard apache2 setup on raspbian ;). Is it true, that the h2 protocol only works (or only make sense) in the 443 vhost and why? I added the code above also to the 80 vhost and didn’t found any problem accessing my nextcloud without explicit “https://” in adress field. But I anyway configured permanent redirect to https, so maybe this skips possible problems.

  • What actually does ProtocolsHonorOrder On? Does it force to try the protocols in the given orden, so in my case first h2, and only if it doesn’t work it will fall back to http/1.1?

  • I also found the h2c protocol, which is advised to use in the basic apache.conf. So is it maybe easier to just add Protocols h2 h2c http/1.1 to the apache.conf itself, if I anyway want to use http2 everywhere possible?

  • I also found the H2Push and H2Direct syntax, which can further improve performance according to some guides. H2Direct seems to be enabled by default for h2c protocol but not for h2. I didn’t understand what it actually does and if it is also useful to enable für h2. Maybe someone can explain this for me? :slight_smile:
    H2Push seems to be enabled by default anyway.

I hope someone here has some deeper knowledge about http/2 and it’s possible settings. The official documentation didn’t really help me.

See here: HTTP/2 - Wikipedia
Can’t say anything to you other questions, since I don’t have any idea about apache (I am using nginx)…

1 Like

Okay, it’s about browser support.

ProtocolsHonorOrder works as expected and is also activated by default, so Protocols h2 h2c http/1.1 should work in every vhost/apache.conf.

Here is some more explanation about H2Direct and the whole topic.

Hello,

Does NC support HTTP/2 then?
If so, what’s the setup?

Thanks in advance.

NC fully supports HTTP/2.

Is there a setup guide for Nginx?

I am writing a guide for nginx here:

will take some time to complete.
It is for nginx following security practices

1 Like

https://docs.nextcloud.com/server/11/admin_manual/installation/nginx_nextcloud_9x.html
Change
listen 443 ssl;
To
listen 443 ssl http2;
You need nginx >= 1.9.5

@ Bernie_O,

Is that all we need?

Thanks.

thats all is need to enable http/2. SSL is necessary for HTTP/2 to work. Browsers dont use HTTP/2 if SSL is not enabled

Cool.
Thanks guys.

Is the setting provided by Bernie_O valid for Apache as well?

On apache I enabled it successfully like this:

a2enmod http2
/etc/apache2/conf-available/http2.conf
	<IfModule http2_module>
	  Protocols h2 h2c http/1.1
	  H2Direct on
	</IfModule>
a2enconf http2
service apache2 restart

Here some more about the module and it’s options: https://httpd.apache.org/docs/2.4/mod/mod_http2.html

1 Like

Great! Thanks a lot for your quick reply!
Cheers,
George

For me it does not help at all, needs to follow this procedure and enable php-fpm: https://techwombat.com/enable-http2-apache-ubuntu-16-04/

@gas85
HTTP/2 and php-fpm do not have something to with each other. You can use both separately. I use HTTP/2 with method above successfully via mod-php. But depending on your cloud usage, php-fpm might be a good alternative (is always) anyway.
Of course your Apache version needs to be hight enough to support HTTP/2. But the guide you followed seems to be wrong there, as the official docs say: Available in version 2.4.17 and later: https://httpd.apache.org/docs/2.4/mod/mod_http2.html

Guide: You want to make Apache use the correct PHP implementation: Correct it totally wrong and irritating wording here, as there is no wrong or right in this, it totally depends on your usage and needs. HTTP/2 again works on both.

I started from easy way, then I try everything from this post, but only what I have was Upgrade: h2,h2c in http header, but nothing else.
Since I use php fpm and enable mpm event and proxy_fcgi it works… without it does not work for me…
System is Ubuntu 16.04 with on it Apache 2.4.29.

@gas85
Now I checked again and found this:

Starting from Apache 2.4.27, the Apache MPM (Multi-Processing Module) prefork no longer supports HTTP/2. This will be indicated in your Apache error log as follows:
AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.

Whoopsie, seems you are right for newest apache versions, didn’t know that and don’t know about the reasons yet.
So good to know, from apache 2.4.27 on you need to switch to e.g. mpm_event/php-fpm…

More on this: HTTP/2 guide - Apache HTTP Server Version 2.5

The reason is that mod_h2 is using threads internally. Running Apache in prefork and using h2 can lead to unexpected (and hard to investigate) errors when PHP is also used as a module.

see also: https://github.com/nextcloud/server/issues/4706#issuecomment-310649209

2 Likes