用nginx进行HTTP2推送?

编程入门 行业动态 更新时间:2024-10-23 09:37:49
本文介绍了用nginx进行HTTP2推送?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在虚拟机上安装了带有wordpress网站和openssl的nginx 1.13.10.我正在尝试测试http2 push.这是我的nginx conf文件:

I install nginx 1.13.10 with a wordpress site and openssl on my virtual machine. I'm trying to test http2 push. Here is my nginx conf file:

pastebin/71ziXeRh server { listen 80 default_server; listen [::]:80 default_server; server_name 192.168.133.21; return 302 $server_name$request_uri; } # Load configuration files for the default server block. server { listen 443 ssl http2; server_name 192.168.133.21; include conf.d/self-signed.conf; #ssl config ssl on; location / { root /var/www/wordpress/current; index index.php index.html index.htm; http2_push /wp-content/themes/twentyseventeen/assets/images/header.jpg; http2_push /wp-content/themes/twentyseventeen/style.css?ver=4.7.4; } error_page 404 /404.html; location = /40x.html { root /usr/share/nginx/html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { root /var/www/wordpress/current; try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }

重新启动nginx,没有错误.但是,当我使用Chrome调试时,没有资源被推送演示图片

Restart nginx and no error. But when I debug it with Chrome no resource was pushed demo image

请告诉我在某处是否做错了事.

Please tell me if I do something wrong somewhere.

推荐答案

这是Chrome的限制.如果您的SSL/TLS证书不受信任(我们可以看到您的SSL/TLS证书不在屏幕截图中),它将忽略推送的资源.即使您跳过粘贴HTTPS错误.同样,此类网站上的资源也无法缓存.

It's a restriction in Chrome. If your SSL/TLS cert is not trusted (as we can see yours is not in the screenshot) it ignores pushed resources. Even if you skip paste the HTTPS error. Similarly resources on such a site cannot be cached.

将证书添加到浏览器的信任库中,这样您将获得绿色的挂锁,并且应该会开始起作用.

Add the certificate to your browser's trust store so you get a green padlock and it should start to work.

类似的问题(但使用Node而不是Nginx)这里.

Similar question (but using Node rather than Nginx) here.

更多推荐

用nginx进行HTTP2推送?

本文发布于:2023-11-01 20:07:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550284.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:nginx

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!