Yas*_*tra 5 django nginx python-3.x
我正在使用 Django 的内置密码重置机制。它会发送一封电子邮件,其中包含一个包含令牌的链接,单击该令牌可用于重置密码。但是,生成的链接正在使用模板:
{% 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 %}
Run Code Online (Sandbox Code Playgroud)
在这里,{{ protocol }}返回的是http而不是https。我的 nginx 服务器会将任何 http 请求重定向到 https 基本链接(主页)。
因此,密码重置链接不起作用,因为生成的链接是错误的。它只是通过 nginx 进入主页。
我该如何解决?
这可能是 nginx 配置中的 X-Forwarded-Protocol 的问题。
您需要将其添加到您的位置块中:
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参阅:https://djangodeployment.com/2017/01/24/fix-djangos-https-redirects-nginx/
| 归档时间: |
|
| 查看次数: |
648 次 |
| 最近记录: |