[Fixed]-How to prevent Django admin from adding changelist filters twice to the URL with active 301 redirect to https?

1👍

You need to set the http headers correctly (most importantly X-Forwarded-Proto), otherwise django doesn’t know that the first request is an https request, and assumes it’s http, so all the links it creates are http links.

location / {
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        uwsgi_pass      project_pass;
        include         uwsgi_params;
}

This would prevent the http links. Also, your rewrite command should have a question mark at the end, so nginx won’t add the GET arguments twice:

location / {
        rewrite ^ https://$host$request_uri? permanent;
}

You might want to consider using the simpler return directive.

location / {
        return 301 https://$host$request_uri;
}
👤noamk

Leave a comment