您好,登录后才能下订单哦!
如何配置openssl和nginx使用http2?这篇文章运用了实例代码展示,代码非常详细,可供感兴趣的小伙伴们参考借鉴,希望对大家有所帮助。
一、配置openssl
openssl版本需大于1.0.2版本
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 使配置生效
openssl version 查看版本
tar xf nginx-1.14.2.tar.gz
cd nginx-1.14.2
vim src/core/nginx.h 去除版本信息,这两行修改成
#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
二、配置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; #强制访问到https
}
server {
listen 443 ssl http2 ; #http2必须用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 ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
location / {
root html;
index index.html index.htm;
}
}
}
上文描述的就是配置openssl和nginx使用http2的方法,具体使用情况还需要大家自己动手实验使用过才能领会。如果想了解更多相关内容,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。