generalmybb

Enable HTTP/2 support with Apache

NOTE: We are in the process of modifying the file structure and configuration for many Bitnami stacks. On account of these changes, the file paths stated in this guide may change depending on whether your Bitnami stack uses native Linux system packages (Approach A), or if it is a self-contained installation (Approach B). To identify your Bitnami installation type and what approach to follow, run the command below:

 $ test ! -f "/opt/bitnami/common/bin/openssl" && echo "Approach A: Using system packages." || echo "Approach B: Self-contained installation."

The output of the command indicates which approach (A or B) is used by the installation, and will allow you to identify the paths, configuration and commands to use in this guide. Refer to the FAQ for more information on these changes.

Bitnami stacks ship with the mod_http2 module installed, but it is not enabled by default. To enable this module, follow these instructions. Once the module is active, follow the steps below:

Approach A: Bitnami installations using system packages

  • Add the following lines in the default Apache HTTP virtual host configuration file at /opt/bitnami/apache2/conf/bitnami/bitnami.conf, inside the default VirtualHost directive, so that it looks like this:

    <VirtualHost _default_:80>
      ...
      Protocols h2 h2c http/1.1
    </VirtualHost>
    
  • Add the following lines in the default Apache HTTPS virtual host configuration file at /opt/bitnami/apache2/conf/bitnami/bitnami-ssl.conf, inside the default VirtualHost directive, so that it looks like this:

    <VirtualHost _default_:443>
      ...
      Protocols h2 h2c http/1.1
    </VirtualHost>
    
  • Add the following lines in any Apache virtual host file defined inside the /opt/bitnami/apache2/conf/vhosts/ directory, inside the default VirtualHost directive for each file, so that it looks like this:

    NOTE: Replace the PORT placeholder with the port number used by the virtual host.

    <VirtualHost 127.0.0.1:PORT _default_:PORT>
      ...
      Protocols h2 h2c http/1.1
    </VirtualHost>
    
  • After modifying the Apache configuration files, restart Apache to apply the changes.

    $ sudo /opt/bitnami/ctlscript.sh restart apache
    

Approach B: Self-contained Bitnami installations

  • Add the following lines in the default Apache virtual host configuration file at /opt/bitnami/apache2/conf/bitnami/bitnami.conf, inside the default VirtualHost directives, so that it looks like this:

    <VirtualHost _default_:80>
      ...
      Protocols h2 h2c http/1.1
    </VirtualHost>
    
    ...
    
    <VirtualHost _default_:443>
      ...
      Protocols h2 h2c http/1.1
    </VirtualHost>
    

    Repeat the above change for any other virtual hosts you may have defined.

  • After modifying the Apache configuration files, restart Apache to apply the changes.

    $ sudo /opt/bitnami/ctlscript.sh restart apache
    
Last modification June 9, 2020