others-how to solve the the http2 parameter requires ngx_http_v2_module problem when using nginx to serve http/2 requests?

1. Purpose

In this post, I will show you how to solve solve the the “http2” parameter requires ngx_http_v2_module problem when using nginx to serve http/2 requests.

Here is my nginx version info shown by nginx -V

nginx version: nginx/1.22.1 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/home/tools/nginx --with-http_ssl_module

But if I turned on the http2 in nginx as follows:

        listen       443 ssl http2;
        server_name  www.xxxx.com;

When trying to start nginx, I got the following problem:

the "http2" parameter requires ngx_http_v2_module



2. Solution

2.1 What is ngx_http_v2_module?

The ngx_http_v2_module module (1.9. 5) provides support for HTTP/2. This module is not built by default, it should be enabled with the –with-http_v2_module configuration parameter.

2.2 The solution

To solve this problem, we need to re-compile the nginx from source, add http2 support.

First we need to find the src code of nginx and then compile it with --with-http_v2_module:

./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_v2_module

make 

cp objs/nginx /home/tool/nginx/sbin/nginx

Then restart your nginx again. It works!



3. Summary

In this post, I demonstrated how to solve the the “http2” parameter requires ngx_http_v2_module problem when using nginx to serve http/2 requests . That’s it, thanks for your reading.