gpt4 book ai didi

apache - 如何为 SSL 页面配置 mod_pagespeed

转载 作者:行者123 更新时间:2023-11-28 21:45:45 26 4
gpt4 key购买 nike

我们有网站,例如http://www.acb.com它指向一个硬件负载平衡器,它应该对两个专用服务器进行负载平衡。每个服务器都运行 apache 作为前端,并使用 mod_proxy 将请求转发到 tomcat。

我们网站的某些页面需要 SSL,例如 https://www.abc.com/loginhttps://www.abc.com/checkout

SSL 在硬件负载平衡器处终止。

当我配置 mod_pagespeed 时,它会压缩、最小化和合并 css 文件,并用绝对 url 重写它们 http://www.abc.com/css/merged.pagespeedxxx.css而不是相对 url/css/merged.pagespeedxxx.css。

它适用于非 ssl 页面,但当我导航到 ssl 页面时,例如 https://www.abc.com/login所有的 css 和 js 文件都被像 chrome 这样的浏览器阻止,因为它们的绝对 url 没有使用 ssl。

我该如何解决这个问题?

最佳答案

检查此 documentation 中的 https 字符串和 this one .

您应该在您的问题中向我们展示您当前的 ModPagespeedMapOriginDomain && ModPagespeedDomain 设置。

据我对这些行的理解:

The origin_specified_in_html can specify https but the origin_to_fetch_from can only specify http, e.g.

ModPagespeedMapOriginDomain http://localhost https://www.example.com

This directive lets the server accept https requests for www.example.com without requiring a SSL certificate to fetch resources - in fact, this is the only way mod_pagespeed can service https requests as currently it cannot use https to fetch resources. For example, given the above mapping, and assuming Apache is configured for https support, mod_pagespeed will fetch and optimize resources accessed using https://www.example.com, fetching the resources from http://localhost, which can be the same Apache process or a different server process.

还有这些:

mod_pagespeed offers limited support for sites that serve content through https. There are two mechanisms through which mod_pagespeed can be configured to serve https requests:

  • Use ModPagespeedMapOriginDomain to map the https domain to an http domain.
  • Use ModPagespeedLoadFromFile to map a locally available directory to the https domain.

解决方案应该是这样的(或带有 ModPagespeedLoadFromFile 的解决方案)

ModPagespeedMapOriginDomain http://localhost https://www.example.com

但是,您的真正问题是apache 不直接接收HTTPS 请求,因为硬件负载平衡器会自行处理。所以 mod-pagespeed 输出过滤器甚至不知道它被请求用于 SSL 域。当它修改 HTML 内容时,可能应用域重写,它无法处理 https 的情况。

所以...一个解决方案(未经测试)将在 apache 服务器上使用另一个虚拟主机,如果需要,仍然是 HTTP,专用于 https 处理。所有与 https 相关的 url(/login/checkout,...)随后将由硬件负载平衡器重定向到该特定域名。比方说 http://secure.acb.com。此名称仅在负载均衡器和前端 apaches 之间使用(并且可以肯定的是,apache 应该将对此 VH 的访问限制为仅负载均衡器)。

然后在这些 http://secure.acb.com 虚拟主机中,mod_pagespeed 将配置为从外部将域重写为 https://www.example.com。像这样的东西:

ModPagespeedMapOriginDomain http://secure.example.com https://www.example.com

最终用户请求是 https://www.example.com/login,负载均衡器管理 HTTPS,通过 http://secure.example.com 与 apache 对话,并且页面结果仅包含对 https://www.example.com/* Assets 的引用。现在,当使用 https 域请求请求这些 Assets 时,您仍然会遇到服务这些 Assets 的问题。因此,硬件负载均衡器应该允许所有这些 Assets url 在 https 域中,并将它们发送到 http://secure.abc.com 虚拟主机(或任何其他静态 VH)。

关于apache - 如何为 SSL 页面配置 mod_pagespeed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14372847/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com