美文网首页HTTP协议原理+实践
4-5 HTTP2的优势和Nginx配置HTTP2的简单使用

4-5 HTTP2的优势和Nginx配置HTTP2的简单使用

作者: 伯纳乌的追风少年 | 来源:发表于2018-12-07 13:54 被阅读0次

Http2的优势:



http2的配置:

proxy_cache_path cache levels=1:2 keys_zone=my_cache:10m;


server {#由http跳转到https
  listen       80 default_server;
  listen       [::]:80 default_server;
  server_name  test.com;
  return 302 https://$server_name$request_uri;
}

server {
  listen       443 http2;
  server_name  test.com;
  http2_push_preload on;#开启http2的push

  ssl on;
  ssl_certificate_key /usr/local/etc/nginx/certs/localhost-privkey.pem;
  ssl_certificate /usr/local/etc/nginx/certs/localhost-cert.pem;

  location / {
    proxy_cache my_cache;
    proxy_pass http://127.0.0.1:8888;
    proxy_set_header Host $host; #nginx对http请求的host进行转发
  }
}


http2的性能测试网站:https://http2.akamai.com/demo/http2-lab.html

相关文章

网友评论

    本文标题:4-5 HTTP2的优势和Nginx配置HTTP2的简单使用

    本文链接:https://www.haomeiwen.com/subject/woiccqtx.html