在CentOS 6.8 x86_64的nginx 1.10.3上开启http2功能
生活随笔
收集整理的這篇文章主要介紹了
在CentOS 6.8 x86_64的nginx 1.10.3上开启http2功能
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
在原有基礎上修改編譯選項來開啟http2
回見
http://blog.csdn.net/tao_627/article/details/60957521在nginx源碼目錄下的configure選項中加入--with-http_v2_module,由于HTTP2需要SSL的支持,因此如缺少--with-http_ssl_module選項,還需要加入--with-http_ssl_module。
如下:
./configure --with-pcre=/usr/local/src/pcre-8.40 \--with-zlib=/usr/local/src/zlib-1.2.11 \
--with-openssl=/usr/local/src/openssl-1.1.0e \
--add-module=/usr/local/src/nginx_modules_demo/ngx_http_mytest_module \
--with-http_ssl_module \
--with-threads \
--with-http_v2_module \
--with-debug
make
make install
注意:中途增加第三方模塊并重新編譯安裝nginx,原有/usr/local/nginx/conf下面的文件并不會覆蓋
配置ssl證書
調(diào)研了一下申請免費證書的基本步驟,發(fā)現(xiàn)首先需要注冊一個合法域名,dns可以解析到這個域名,才能針對這個域名申請證書。
這個對于只做demo的我來說,比較難辦。于是我找到一個討巧的方法,直接去公司線上找一個小文件的服務域名的證書和私鑰,配置在本地測試服務器上。
過程略。
比如說,這個域名是www.xyaz.cn,它的服務器證書和私鑰分別記為server.crt和server.key文件。
下面配置nginx.conf,得到
?
# HTTPS serverserver {listen 443 ssl http2 default_server;server_name localhost;ssl on;ssl_certificate /usr/local/nginx/conf/server.crt;ssl_certificate_key /usr/local/nginx/conf/server.key;ssl_session_cache shared:SSL:1m;ssl_session_timeout 5m;ssl_ciphers HIGH:!aNULL:!MD5;ssl_prefer_server_ciphers on;location / {root html;index index.html index.htm;}}
檢查nginx配置是否正確?
/usr/local/nginx/sbin/nginx -t
編譯帶有http2功能的curl作為本地測試客戶端
http://blog.csdn.net/tao_627/article/details/77263080
測試nginx的http2功能
vim /etc/hosts
添加-行
127.0.0.1 ? www.xyaz.cn
本地測試
curl --http2 -vo test.out https://www.xyaz.cn/
參考文獻
http://www.cnblogs.com/bugutian/p/6628455.html
總結(jié)
以上是生活随笔為你收集整理的在CentOS 6.8 x86_64的nginx 1.10.3上开启http2功能的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在CentOS 6.8 x86_64上安
- 下一篇: 在Ubuntu 16.04.1 LTS上