---
slug: "django-http-https-absolute-uri"
title: "Issues with Redirect URLs Being HTTP Instead of HTTPS in Python Social Auth Django or AllAuth"
description: "One-liner to count upgradable packages with `apt list --upgradable`, plus a shell script to surface the number in the MOTD login banner."
url: "https://www.ytyng.com/en/blog/django-http-https-absolute-uri"
publish_date: "2018-07-12T11:24:16Z"
created: "2018-07-12T11:24:16Z"
updated: "2026-05-11T13:21:37.279Z"
categories: ["Django"]
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20230812/bee87ea0cc7d438cb1e027dc30dac52f.png.webp?width=768"
has_video: false
has_music: false
video_urls: []
music_urls: []
lang: "en"
---

# Issues with Redirect URLs Being HTTP Instead of HTTPS in Python Social Auth Django or AllAuth

<p>Django Social Auth's Django module and AllAuth's redirection protocol scheme becoming HTTP instead of HTTPS (callback_uri, redirect_uri, destination) was troublesome.</p>
<p></p>
<h2>Settings in Django</h2>
<p>To create the URI, <code>django.http.request.HttpRequest.build_absolute_uri</code> is used.</p>
<p>Therefore, in your settings, define:</p>
<pre>SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')</pre>
<p></p>
<h2>Settings in nginx</h2>
<p>If nginx is handling HTTPS requests, configure nginx as follows:</p>
<pre>location / {<br />    proxy_set_header X-Forwarded-Proto $scheme;<br />    ...</pre>
<p></p>
<p>Something like this,</p>
<p>If nginx is handling HTTP requests instead of HTTPS, for example, when HTTPS is terminated at an ELB (Elastic Load Balancer), use:</p>
<pre>location / {<br />    proxy_set_header X-Forwarded-Proto https;<br />    ...</pre>
<p>You should directly pass the HTTPS header.</p>
<p></p>
<p></p>
