Apache HTTP Server: Difference between revisions

Created page, merged Securing Apache with an SSL/TLS certificate article here
 
m HTTP/2 Support: Updated what is needed to support HTTP/2, spell checked
Line 39: Line 39:
== HTTP/2 Support ==
== HTTP/2 Support ==


Normal websites use HTTP 1.1 which was released in 1999, 17 years ago and the web has changed a lot since then. Based on Google's SPDY protocol, HTTP/2 allows, amongst other things, native compression, security (when implemented with TLS), concurrent connections and prioitization. This makes the connection much more robust than before.
Normal websites use HTTP 1.1 which was released in 1999, 17 years ago and the web has changed a lot since then. Based on Google's SPDY protocol, HTTP/2 allows, amongst other things, native compression, security, concurrent connections and prioritization. This makes the connection much more robust than before.


HTTP/2 is support with Apache 2.4.12 with the addition of the mod_http2 module and is natively supported from Apache 2.4.17 without mod_http2 module. In this article, we will focus on the latter.
HTTP/2 is supported with Apache 2.4.12 with the addition of the mod_http2 module. It is natively supported with Apache >2.4.17 without the mod_http2 module. In this article, we will focus on the latter.


* In the software manager in YaST, you will need to make sure that <code>nghttp2</code> is installed.
There are a few prerequisites that are required for HTTP/2 to work:
 
* You must have a valid TLS certificate setup and working correctly.
* If you are using PHP, it must be implemented by the FPM method. Using mod_php[x] will disable HTTP/2.
 
To enable HTTP/2:
 
* In the software manager in YaST, you will need to make sure that <code>libnghttp2-14</code> shared library is installed.
* Open a terminal window
* Open a terminal window
* Type <code>sudo a2enmod http2</code>. This will enable the built in module in Apache.
* Type <code>sudo a2enmod http2</code>. This will enable the built in module in Apache.
* Open kwrite and open the file <code>/etc/apache2/httpd.conf</code>
* Open kwrite and open the file <code>/etc/apache2/httpd.conf</code>
* At the end of the file add the following lines:
* At the end of the file add the following line:
  Protocols h2 http/1.1
  Protocols h2 http/1.1
Protocols h2c http/1.1
* The first line adds support for HTTP/2 over a HTTPS connection and must be used in conjunction with a TLS certificate. This is the default use case. The second line adds support for HTTP/2 over an unencrypted HTTP connection. Not many browsers support this option if at all as it is defined that HTTP/2 is to be used with HTTPS. You may use either or both lines to suit your use case. On this server, only the first line has been enabled.
* Save the configuration file once you have added your appropriate lines
* Save the configuration file once you have added your appropriate lines
* Restart Apache by typing <code>sudo service apache2 restart</code>. If you are returned to the command prompt, you have successfully enabled it. You will get an error message and Apache will refuse to start if there is a configuration problem.
* Restart Apache by typing <code>sudo service apache2 restart</code>. If you are returned to the command prompt, you have successfully enabled it. You will get an error message and Apache will refuse to start if there is a configuration problem.