nginx1.13.9如何跨域配置server push?
最近nginx.1.13.9版本已经支持server push了,
Changes with nginx 1.13.9 20 Feb 2018
*) Feature: HTTP/2 server push support; the "http2_push" and
"http2_push_preload" directives.
*) Bugfix: "header already sent" alerts might appear in logs when using
cache; the bug had appeared in 1.9.13.
*) Bugfix: a segmentation fault might occur in a worker process if the
"ssl_verify_client" directive was used and no SSL certificate was
specified in a virtual server.
*) Bugfix: in the ngx_http_v2_module.
*) Bugfix: in the ngx_http_dav_module.
具体指令部分语法:
Syntax: http2_push uri | off;
Default:
http2_push off;
Context: http, server, location
This directive appeared in version 1.13.9.
Pre-emptively sends (pushes) a request to the specified uri along with the response to the original request. Only relative URIs with absolute path will be processed, for example:
http2_push /static/css/main.css;
The uri value can contain variables.
Several http2_push directives can be specified on the same configuration level. The off parameter cancels the effect of the http2_push directives inherited from the previous configuration level.
Syntax: http2_push_preload on | off;
Default:
http2_push_preload off;
Context: http, server, location
This directive appeared in version 1.13.9.
Enables automatic conversion of preload links specified in the “Link” response header fields into push requests.
如果是使用第一种方法。那么要求推送的资源必须是绝对路径,这个绝对路径是相对当前domain的,比如当前的页面是www.example.com,我要推送的资源是 www.example.com/demo.css,那么我只要在www.example.com的主机配置文件:
http2_push /demo.css;
即可了,但是,如果我要推送的是跨域的资源呢?比如,assets.example.com/demo.css
我该如何操作?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不能,因为不同域名不能使用同一个TCP连接。