Issues with Redirect URLs Being HTTP Instead of HTTPS in Python Social Auth Django or AllAuth
Django
2018-07-12 11:24 (8 years ago)

Django Social Auth's Django module and AllAuth's redirection protocol scheme becoming HTTP instead of HTTPS (callback_uri, redirect_uri, destination) was troublesome.
Settings in Django
To create the URI, django.http.request.HttpRequest.build_absolute_uri is used.
Therefore, in your settings, define:
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
Settings in nginx
If nginx is handling HTTPS requests, configure nginx as follows:
location / {
proxy_set_header X-Forwarded-Proto $scheme;
...
Something like this,
If nginx is handling HTTP requests instead of HTTPS, for example, when HTTPS is terminated at an ELB (Elastic Load Balancer), use:
location / {
proxy_set_header X-Forwarded-Proto https;
...
You should directly pass the HTTPS header.
Please rate this article (No signup or login required)
Currently unrated
Related posts
Return Login and Redirect Views by Hardcoding Social Account Provider in django-allauth (When Using AWS Cognito, etc.)
How to Set Up API Proxy to Other Services in Nuxt3
Using Vue.js Webpack Dev Server Proxy for Social Provider Authentication with Django + Python Social Auth
Failure of Django CSRF Token Authentication: ELB -> Apache2 -> uwsgi
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.
We look forward to discussing your development needs.