request.is_secure() always returns false with uwsgi server

django, https, nginx, uwsgi

Solution

For `gunicorn` server fixed with:

Add this line to `nginx.conf` file:

proxy_set_header        X-Forwarded-Proto           $scheme;

And add this line to `settings.py` file:

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

Problem

We are using Ngnix + uWSGI setup for our Django-based application. Our problem is that `request.is_secure()` always returns false even though we are serving content on https. As mentioned in the uWSGI documentation, I have set `uwsgi_param UWSGI_SCHEME $scheme` in nginx configuration or uwsgi_params, but it is of no use. We also have Nginx + apache based setup for the same application, there it works just fine. Any help will be appreciated. Thanks in advance.

Original source