gpt4 book ai didi

Django 密码重置生成 http 链接而不是 https

转载 作者:行者123 更新时间:2023-12-04 13:43:08 25 4
gpt4 key购买 nike

我正在使用 Django 的内置密码重置机制。它会发送一封电子邮件,其中包含一个包含 token 的链接,单击该链接可用于重置密码。但是,正在生成的链接正在使用模板:

{% trans "Please go to the following page and choose a new password:" %}
{% block reset_link %}
{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}
{% endblock %}

在这里, {{ protocol }}正在返回 http 而不是 https。
我的 nginx 服务器会将任何 http 请求重定向到 https 基本链接(主页)。

因此,由于生成的链接错误,密码重置链接不起作用。它只是通过 nginx 进入主页。

我该如何解决?

最佳答案

这可能是 nginx 配置中 X-Forwarded-Protocol 的问题。

您需要将其添加到您的位置块中:

proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;

更多信息请参见: https://djangodeployment.com/2017/01/24/fix-djangos-https-redirects-nginx/

关于Django 密码重置生成 http 链接而不是 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54011207/

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