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

  • Home
  • SEARCH
  • 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 8886835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:39:18+00:00 2026-06-14T21:39:18+00:00

I get a redirect loop when using SSL middleware to redirect certain urls to

  • 0

I get a redirect loop when using SSL middleware to redirect certain urls to HTTPS. What should I do?

My nginx config is set up to forward requests to gunicorn.

  • 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-06-14T21:39:19+00:00Added an answer on June 14, 2026 at 9:39 pm

    There are a couple of steps here.

    First of all, modify the way your middleware checks for SSL:

      def _is_secure(self, request):
        if request.is_secure():
          return True
    
        if 'HTTP_X_SSL_PROTOCOL' in request.META:
          return True
    
        return False
    

    Then change your nginx config as follows:

    server {
        listen 80;
        listen 443 ssl;
    
        ...
    
        location / {
    
            ...
            proxy_set_header X-SSL-Protocol $ssl_protocol;
            proxy_pass http://localhost:8000/;
        }
    }
    

    proxy_set_header will only be passed on if ssl_protocol is not null, i.e., it’s a secure connection.

    Restart nginx and you’re done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the Post/Redirect/Get pattern on a form of mine. I've never used this
I use mod_rewrite/.htaccess for pretty URLs. I forward all the requests to my index.php,
I'm getting a redirect loop error for using header(); after mysql_num_rows(); if I replace
I'm getting an infinite redirect loop after adding SSL support to my site. I'm
I am developing php application with cURL library. I would like to get redirect
is there any reason to use the post-redirect-get (prg) for a request that you
I would like to get to know how to redirect output of some program
I want to redirect to home page if session get invalid. My spring-servlet.xml is
For example in some cases after POST or GET request I want to redirect
I'm trying to clean up my URLs using mod_rewrite in my .htaccess files. Let's

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.