天天看點

Nginx學習(十四) nginx開啟HTTP2協定

目前隻有https才支援http2協定,nginx需要開啟支援http2的子產品with-http_v2_module

安裝過程參考上一篇:https://blog.csdn.net/u011943534/article/details/118384917

安裝過程中,添加http2即可

./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_v2_module
make & make install
           

在nginx.conf中server的listener中添加http2支援

server {
                    limit_conn conn_aming 600;

        listen   1443 ssl http2;
        server_name  172.16.10.168;

                ssl_certificate ../sslkey/server.crt;
                ssl_certificate_key ../sslkey/server.key.unsecure;
                ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
                ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
                    ssl_prefer_server_ciphers on;

                location /* {
                        root html;
                        index index.html index.htm;
                }

                location /demo {
                        proxy_pass http://newframe/demo;
                        proxy_set_header X-forward-for $proxy_add_x_forwarded_for;
                        proxy_set_header Host $host;
                        proxy_set_header X-Real-Ip $remote_addr;
                        limit_rate_after 51200k;
                        limit_rate 800000k;
                        limit_req zone=req_aming burst=500;
                        client_max_body_size 512m;

                }

           

使用浏覽器通路,通過控制台檢視http協定,發現h2就是已經使用http2協定了

Nginx學習(十四) nginx開啟HTTP2協定

繼續閱讀