Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7443533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:20:41+00:00 2026-05-29T11:20:41+00:00

I have python/django app on Heroku (Cedar stack) and would like to make it

  • 0

I have python/django app on Heroku (Cedar stack) and would like to make it accessible over https only. I have enabled the “ssl piggyback”-option, and can connect to it via https.

But what is the best way to disable http access, or redirect to https?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:20:43+00:00Added an answer on May 29, 2026 at 11:20 am

    Combining the answer from @CraigKerstiens and @allanlei into something I have tested, and verified to work. Heroku sets the HTTP_X_FORWARDED_PROTO to https when request is ssl, and we can use this to check:

    from django.conf import settings
    from django.http import HttpResponseRedirect
    
    
    class SSLMiddleware(object):
    
        def process_request(self, request):
            if not any([settings.DEBUG, request.is_secure(), request.META.get("HTTP_X_FORWARDED_PROTO", "") == 'https']):
                url = request.build_absolute_uri(request.get_full_path())
                secure_url = url.replace("http://", "https://")
                return HttpResponseRedirect(secure_url)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a App Engine/Python/Django application which has grown and been modified over the
I have a Django app written in Python 2.5 and I plan to upgrade
I have written a Django app that makes use of Python threading to create
Following the Heroku tutorial but I have already created a rather complex Django app
I have a python/django application that runs on the google app engine. My views.py
I'm new to python, django and google app engine. All great tools and have
Suppose I have a Django app (for example, myapp ) and a Python script
If I have the following models in a Python (+ Django) App Engine app:
I have a string in a django/python app and need to search it for
I have a Python program (with Django - does this matter?) that I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.