nginx http2 push 试用
nginx 已经很早就支持http2,今天证书过期,重新申请了一个,同时测试下http2 的push 功能
环境准备
- 证书
这个结合自己的实际去申请,我使用免费的letsencrypt,支持泛域名证书,参考https://www.cnblogs.com/rongfengliang/p/8579181.html - 配置
nginx.conf
worker_processes auto;
events {
worker_connections 65535;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
real_ip_header X-Forwarded-For;
server {
listen 443 ssl http2;
server_name dalong.apicaddy.com;
ssl_certificate /etc/nginx/apicaddy-cert.pem;
ssl_certificate_key /etc/nginx/apicaddy-key.pem;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH:AES256+EDH';
ssl_prefer_server_ciphers on;
root /usr/share/nginx/html;
location =/index.html {
http2_push /index.css;
http2_push /app.js;
http2_push /app.css;
}
}
}
- docker-compose 文件
version: "3"
services:
nginx:
build: ./
volumes:
- "./apicaddy-cert.pem:/etc/nginx/apicaddy-cert.pem"
- "./apicaddy-key.pem:/etc/nginx/apicaddy-key.pem"
- "./nginx.conf:/etc/nginx/nginx.conf"
ports:
- "443:443"
- dockerfile
FROM nginx
COPY app.js /usr/share/nginx/html/
COPY app.css /usr/share/nginx/html/
COPY index.css /usr/share/nginx/html/
COPY index.html /usr/share/nginx/html/
测试
- 安装nghttp2
yum insatll nghttp2
- 测试
nghttp -ans https://dalong.apicaddy.com
- 效果
nghttp -ans https://dalong.apicaddy.com
[WARNING]: -a, --get-assets option is ignored because
the binary was not compiled with libxml2.
[WARNING] Certificate verification failed: unable to verify the first certificate
***** Statistics *****
Request timing:
responseEnd: the time when last byte of response was received
relative to connectEnd
requestStart: the time just before first byte of request was sent
relative to connectEnd. If '*' is shown, this was
pushed by server.
process: responseEnd - requestStart
code: HTTP status code
size: number of bytes received as response body without
inflation.
URI: request URI
see http://www.w3.org/TR/resource-timing/#processing-model
sorted by 'complete'
id responseEnd requestStart process code size request path
13 +1.83ms +156us 1.67ms 200 209 /
2 +1.85ms * +1.70ms 150us 200 26 /index.css
4 +1.86ms * +1.73ms 127us 200 134 /app.js
6 +1.88ms * +1.74ms 135us 200 37 /app.css
参考资料
https://www.cnblogs.com/rongfengliang/p/8579181.html
https://github.com/rongfengliang/nginx-http2-push-demo
https://www.nginx.com/blog/nginx-1-13-9-http2-server-push/
nginx http2 push 试用的更多相关文章
- Nginx http2.0
109/110 HTTP2.0协议 优势必须使用TLS加密 传输数据量大幅减少 1:以二进制格式传输 2:标头压缩(header做压缩) 多路复用及相关功能 : 消息优先级 (比如样式表先渲染页面那 ...
- nginx brotli 压缩试用
brotli 的压缩比相对gzip 有好多提升 测试试用docker 测试代码 https://github.com/rongfengliang/rollup-babel-demolibrary 运行 ...
- nginx ngx_http_image_filter_module 简单试用
nginx包含了一个ngx_http_image_filter_module 模块,我们可以方便的进行图片的缩略图,平时一些简单的功能 已经够用了 环境准备 为了简单使用docker-compose ...
- nginx unit 安装试用
1. yum 源 nano /etc/yum.repos.d/unit.repo 内容 [unit] name=unit repo baseurl=https://packages.nginx.org ...
- nginx unit java 试用
unit 当前已经支持java了,当时支持基于servlet 的开发模式,以下是一个简单的学习 基于官方的demo 环境准备 docker-compose文件 version: "3&q ...
- http2 技术整理 nginx 搭建 http2 wireshark 抓包分析 server push 服务端推送
使用 nginx 搭建一个 http2 的站点,准备所需: 1,域名 .com .net 均可(国内域名需要 icp 备案) 2,云主机一个,可以自由的安装配置软件的服务器 3,https 证书 ht ...
- nginx的安装
1,,nginx的安装 为什么使用nginx我就不多说了,很优秀的,请再行google 在安装前,先安装pcre,安装zlib,安装openssl,以及一些其他包 yum install -y gcc ...
- HTTP2特性预览和抓包分析
背景 近年来,http网络请求量日益添加,以下是httparchive统计,从2012-11-01到2016-09-01的请求数量和传输大小的趋势图: 当前大部份客户端&服务端架构的应用程序, ...
- openresty(nginx)、lua、drizzle调研
一.概述: 1.研究目标:nginx中使用lua脚本,及nginx直接访问mysql,redis 2.需要安装的内容: openresty,mysql,redis 3.OpenResty (也称为 n ...
随机推荐
- ios 设置本地化显示的app名称
内容的本地化这里不做介绍! 名称的本地化: 1.新建一个 Strings File文件,命名为InfoPlist,注意这里一定要命名为InfoPlist! 2.设置本地化信息:选择需要的语言! 3.填 ...
- 关于collectionview布局的坑
不知道写了多少次collectionview,步了很多坑,现在看来虽然达到了自己想要的结果,却不知道其中所以然.还是总结一下,免得再走弯路: 场景是这样的,我要定制一个显示选择图片的排列,想要实现横向 ...
- Aizu - 2681(括号匹配)
Problem Statement You are given nn strings str1,str2,…,strnstr1,str2,…,strn, each consisting of ( an ...
- python生产者消费者模型优点
生产者消费者模型:解耦,通过队列降低耦合,支持并发,生产者和消费者是两个独立的并发体,他们之间使用缓存区作为桥梁连接,生产者指望里丢数据,就可以生产下一个数据了,消费者从中拿数据,这样就不会阻塞,影响 ...
- 使用grafana cli重置grafana密码
Grafana CLIgrafana cli是grafana server自带的一个小巧的二进制工具,用来在运行grafana server的机器上执行命令.插件grafana cli工具允许你安装升 ...
- SpringMvc使用FastJson做为json的转换器(注解方式)
在使用XML方式配置项目,使用fastjson做为Json转换器时通常的在XML内添加如下的配置: <mvc:message-converters register-defaults=" ...
- Web服务器使用基于纯文本表单的身份验证——.net(未完待续)
asp.net 表单验证方式 Asp.net的身份验证有有三种,分别是"Windows | Forms| Passport",其中又以Forms验证用的最多,也最灵活. 根据实际需 ...
- 清除chrome浏览器HSTS缓存
如果你的网站启用了HSTS 在chrome中会用缓存效果,即使你的站点取消了HSTS,下次访问时,仍旧会自动给你重定向到HSTS. 那么如何清除 HSTS呢? chrome://net-interna ...
- php经典算法实现(转)
<? //-------------------- // 基本数据结构算法 //-------------------- //二分查找(数组里查找某个元素) function bin_s ...
- 【opencv基础】imwrite函数与图像存储质量
前言 std::vector<int> compression_params; compression_params.push_back(CV_IMWRITE_JPEG_QUALITY); ...