Apache2 with http/2.0

Nextcloud with http/2.0

You can update your system with unsupported packages from this untrusted but recommended PPA by adding ppa:ondrej/apache2 to your system’s Software Sources. Add the following repository to your system:

sudo -s

add-apt-repository ppa:ondrej/apache2
apt update

and upgrade your Apache2 from v. 2.4.18 to ≥ 2.4.29:

apt upgrade -y

Enable the new module http2

a2enmod http2

Create a new http2.conf

vi /etc/apache2/conf-available/http2.conf

and add all the following rows:

<IfModule http2_module>
Protocols h2 h2c http/1.1
H2Direct on

Enable the http2.conf by running

a2enconf http2

Restart your Apache2

service apache2 restart

and enjoy http/2.0 for your entire Apache2. If you don’t want to enable http/2.0 for your entire Apache2 webserver but in particular for Nextcloud, just disable the previous enabled configuration by running

a2disconf http2

and enhance your ssl-vhost file (nextcloudssl.conf):

vi /etc/apache2/sites-available/nextcloudssl.conf

Amend the red ones in your configuration file:

SSLEngine on
Protocols h2 h2c http/1.1
H2Push on
H2PushPriority * after
H2PushPriority text/css before
H2PushPriority image/jpg after 32
H2PushPriority image/jpeg after 32
H2PushPriority image/png after 32
H2PushPriority application/javascript interleaved
SSLOptions +StrictRequire

Again restart your Apache2 and http2 is up and running for Nextcloud only.
Many thanks to @Simon Bauer.

Carsten Rieger