gpt4 book ai didi

nginx - 预渲染无法在 Nginx 上使用 https

转载 作者:行者123 更新时间:2023-12-02 09:39:17 27 4
gpt4 key购买 nike

我在 Nginx 上运行的应用程序中包含预渲染时遇到问题,我定义了一个简单的规则,用于将所有 http 请求重写为 https ,但是预渲染在 GoDaddy 证书上运行的 https 时遇到一些问题,它会缓存页面但内容是空白的。我已经在 http 上测试了它,它工作正常,我现在尝试的是,如果我的 http_user_agent 是 Prerender,我想保持 http url 完整,否则将 url 重写为 https。

欢迎任何帮助/评论/建议。

最佳答案

刚刚在预渲染处理 https 重定向时遇到了同样的问题。在我们的例子中,快速解决方案是在预渲染节点配置中强制使用 https 协议(protocol)(我认为任何其他中间件都应该存在这样的选项)。

var prerender = require('prerender-node');
prerender.protocol = 'https';

但毕竟这似乎是由于nginx配置错误导致的,它没有传递x-forwarded-proto header ,否则应该由中间件自动处理https://github.com/prerender/prerender-node/blob/master/index.js#L235-L237

关于nginx - 预渲染无法在 Nginx 上使用 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23863558/

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