nginx 已经很早就支持http2,今天证书过期,重新申请了一个,同时测试下http2 的push 功能

环境准备

 
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 试用的更多相关文章

  1. Nginx http2.0

    109/110 HTTP2.0协议 优势必须使用TLS加密 传输数据量大幅减少 1:以二进制格式传输  2:标头压缩(header做压缩) 多路复用及相关功能 : 消息优先级 (比如样式表先渲染页面那 ...

  2. nginx brotli 压缩试用

    brotli 的压缩比相对gzip 有好多提升 测试试用docker 测试代码 https://github.com/rongfengliang/rollup-babel-demolibrary 运行 ...

  3. nginx ngx_http_image_filter_module 简单试用

    nginx包含了一个ngx_http_image_filter_module 模块,我们可以方便的进行图片的缩略图,平时一些简单的功能 已经够用了 环境准备 为了简单使用docker-compose ...

  4. nginx unit 安装试用

    1. yum 源 nano /etc/yum.repos.d/unit.repo 内容 [unit] name=unit repo baseurl=https://packages.nginx.org ...

  5. nginx unit java 试用

    unit 当前已经支持java了,当时支持基于servlet 的开发模式,以下是一个简单的学习 基于官方的demo 环境准备 docker-compose文件   version: "3&q ...

  6. http2 技术整理 nginx 搭建 http2 wireshark 抓包分析 server push 服务端推送

    使用 nginx 搭建一个 http2 的站点,准备所需: 1,域名 .com .net 均可(国内域名需要 icp 备案) 2,云主机一个,可以自由的安装配置软件的服务器 3,https 证书 ht ...

  7. nginx的安装

    1,,nginx的安装 为什么使用nginx我就不多说了,很优秀的,请再行google 在安装前,先安装pcre,安装zlib,安装openssl,以及一些其他包 yum install -y gcc ...

  8. HTTP2特性预览和抓包分析

    背景 近年来,http网络请求量日益添加,以下是httparchive统计,从2012-11-01到2016-09-01的请求数量和传输大小的趋势图: 当前大部份客户端&服务端架构的应用程序, ...

  9. openresty(nginx)、lua、drizzle调研

    一.概述: 1.研究目标:nginx中使用lua脚本,及nginx直接访问mysql,redis 2.需要安装的内容: openresty,mysql,redis 3.OpenResty (也称为 n ...

随机推荐

  1. uitableviewcell textlabel detailtextLabel 换行的位置及尺寸问题

    我们在使用uitableView的时候,一些简单的cell样式其实是不需要自定义的,但是系统的方法又似乎又无法满足需要,这时候我们就需要在系统上做一些改变来达到我们的需求: 像这种cell,简单分析下 ...

  2. bs4 CSS选择器

    #https://www.crummy.com/software/BeautifulSoup/bs4/doc/index.zh.html#find-all #beautifulSoup可以解析HTML ...

  3. (C/C++学习笔记) 三. 作用域和可见性

    三. 作用域和可见性 ● 标识符的作用域 标识符的作用域是标识符在程序源代码中的有效范围,从小到大分为函数原型作用域.块作用域(局部作用域),文件作用域(全局作用域). 1. 函数原型作用域 函数原型 ...

  4. Linux学习 :移植linux-3.4.83到JZ2440开发板

    一.编译环境搭建: 1.linux源码下载:https://www.kernel.org/ (最新)  https://mirrors.edge.kernel.org/pub/linux/kernel ...

  5. Xilinx 7 series FPGA multiboot技术的使用(转)

    reference:https://www.cnblogs.com/chensimin1990/p/9067629.html 当升级程序有错误的时候,系统会启动golden bitstream 注意: ...

  6. centos7创建docker tomcat镜像

    1 准备宿主系统 准备一个 CentOS 7操作系统,具体要求如下: 必须是 64 位操作系统 建议内核在 3.8 以上 通过以下命令查看您的 CentOS 内核: 1 # uname -r 2 安装 ...

  7. DevExpress WinForms v18.2新版亮点(二)

    行业领先的.NET界面控件2018年第二次重大更新——DevExpress v18.2日前正式发布,本站将以连载的形式为大家介绍各版本新增内容.本文将介绍了DevExpress WinForms v1 ...

  8. fk的使用细节

    在seiman的博客fk2.3的用法笔记一文中,介绍了当震中距很大时,fk在使用时需要加上-f,这一展平变换的选项. 另外,nt*dt为最终数据的总长度,当震中距为远震范围时,such as:40°, ...

  9. activemq 生产消费模式,订阅发布模式不同类型数据传输

    1.项目结构 2. activemq-pom pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns ...

  10. python+requests+excel 接口自动化框架

    一.项目框架如图: 1.common :这个包都是一些公共的方法,如:手机号加解密,get/post接口请求的方法封装,接口鉴权,发邮件,读写excel文件方法等等 2.result:存放每次运行的l ...