zoukankan      html  css  js  c++  java
  • nginx http2 push 试用

    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/

  • 相关阅读:
    快速排序
    冒泡排序
    选择排序
    合并排序
    插入排序
    跟我一起阅读Java源代码之HashMap(三)
    跟我一起阅读Java源代码之HashMap(二)
    跟我一起阅读Java源代码之HashMap(一)
    Apache2.2 + tomcat7 服务器集群配置
    Spring+Hibernate实现动态SessionFactory切换(改进版)
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/10156093.html
Copyright © 2011-2022 走看看