How to configure openssl and nginx to use http2
How do I configure openssl and nginx to use http2? This article uses the example code to show, the code is very detailed, which can be used for reference by interested friends. I hope it will be helpful to you.
1. Configure openssl
Openssl version must be greater than 1.0.2 version
Yum install-y gcc zlib-devel pcre-devel
Wget https://www.openssl.org/source/openssl-1.1.0g.tar.gz
Tar zxvf openssl-1.1.0g.tar.gz
Cd openssl-1.1.0g
. / config-- prefix=/usr/local/openssl shared zlib
Make & & make install
Mv / usr/bin/openssl / usr/bin/openssl.old
Ln-s / usr/local/openssl/bin/openssl / usr/bin/openssl
Ln-s / usr/local/openssl/include/openssl / usr/include/openssl
Ln-s / usr/local/openssl/lib/libssl.so.1.1 / lib/x86_64-linux-gnu
Echo / usr/local/openssl/lib > > / etc/ld.so.conf
Ln-s / usr/local/openssl/lib/libssl.so / usr/local/lib64/libssl.so
Ln-s / usr/local/openssl/lib/libcrypto.so / usr/local/lib64/libcrypto.so
Ldconfig-v makes the configuration effective
Openssl version View version
Tar xf nginx-1.14.2.tar.gz
Cd nginx-1.14.2
Vim src/core/nginx.h removes the version information, and these two lines are modified to
# define NGINX_VERSION ""
# define NGINX_VER "Tengine/" NGINX_VERSION
. / configure-- prefix=/usr/local/nginx-- with-http_v2_module-- with-http_ssl_module
Make & & make install
Cd / usr/local/nginx
2. Configure nginx.conf
Vim conf/nginx.conf
Http {
Include mime.types
Default_type application/octet-stream
Sendfile on
Tcp_nopush on
Keepalive_timeout 65
Gzip_min_length 1k
Gzip_comp_level 6
Gzip on
Gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/png application/vnd.ms-fontobject font/ttf font/opentype font/x-woff image/svg+xml
Server {
Listen 80
Server_name abc.com
Rewrite "^ / (. *) $" https://abc.com$1; # forces access to https
}
Server {
Listen 443 ssl http2; # http2 must use https
Server_name abc.com
Ssl_certificate / root/ssl/fullchain.crt
Ssl_certificate_key / root/ssl/private.pem
Ssl_protocols TLSv1.1 TLSv1.2
Ssl_ciphers ECDHEMUR AES128MUG CMUM SHA256 Flex HIGHVOV A NULLLOR MD5 RC4 RC4
Ssl_prefer_server_ciphers on
Ssl_session_cache shared:SSL:1m
Ssl_session_timeout 5m
Location / {
Root html
Index index.html index.htm
}
}
}
The method described above is how to configure openssl and nginx to use http2, and the specific usage needs to be used in a hands-on experiment. If you want to know more about it, welcome to follow the industry information channel!