码迷,mamicode.com
首页 > Web开发 > 详细

nginx支持HTTP2的配置过程

时间:2017-03-27 22:13:25      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:name   启动   服务器   .gz   签名   sign   config   crt   过程   

一、获取安装包

http://zlib.net/zlib-1.2.11.tar.gz 

https://www.openssl.org/source/openssl-1.0.2e.tar.gz (openssl的版本必须在1.0.2e及以上)

http://nginx.org/download/nginx-1.10.3.tar.gz   (nginx的版本必须在1.9.5以上)

二、解压三个包到相同目录编译nginx

 ./configure --prefix=/usr/local/nginx --with-openssl=../openssl-1.0.2e --with-pcre --with-zlib=../zlib-1.2.11 --with-stream --with-stream_ssl_module --with-http_ssl_module --with-http_v2_module --with-threads 
make
make install

三、配置运行

1.配置nginx伪证书

步骤1: 到需要放置证书的目录(选在nginx的conf目录下就可以),建立服务器的私钥(此过程需输入密码短语)

openssl genrsa -des3 -out server.key 1024

步骤2: 创建证书签名请求csr

openssl req -new -key server.key -out server.csr

步骤3:对于使用上面私钥启动具有ssl功能的nginx,有必要移除输出的密码

cp server.key server.key.org
openssl rsa -in server.key.org -out server.key

步骤4: 使用上面的私钥和CSR对证书进行签名

openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

步骤5:配置nginx

    server {
        listen       443 ssl http2;
        server_name  localhost;

        ssl_certificate     server.crt;
        ssl_certificate_key  server.key;
    }

步骤6:启动nginx并用firefox浏览器访问

(firefox浏览器的版本必须在35以上,并且在"about:config"中开启了"network.http.spdy.enabled.http2draft"选项)

访问后查看报文,协议版本是否为HTTP 2.0和firefox是否插入了自己的头"X-Firefox-Spdy:"

四、参考网址

http://wiki.jikexueyuan.com/project/http-2-explained/firefox.html

https://my.oschina.net/leicc/blog/601293?p={{totalPage}}

nginx支持HTTP2的配置过程

标签:name   启动   服务器   .gz   签名   sign   config   crt   过程   

原文地址:http://www.cnblogs.com/bugutian/p/6628455.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!