Brandon Konkle
Brandon Konkle

Software engineer, type system nerd, Rust explorer, Postgres fan, Linux enthusiast, supporter of social justice, loving husband and father, avid comic reader.

I’m a web application developer with nearly 15 years of experience creating high performance applications on the front & back end. I manage a team at Formidable Labs and help clients tackle big ideas.

Share


Tags


uWSGI and Django Secure Requests

A colleague and I ran into a frustrating situation this evening when transitioning a site from Apache and modwsgi to uWSGI. Django's request.is_secure() wasn't working correctly. After much Googling and shouting at the SSH console, we finally discovered the UWSGISCHEME uWSGI parameter.

To fix the issue, we edited /etc/nginx/uwsgiparams (which originally comes from nginx/uwsgiparams in the uWSGI tarball) and added an additional param at the bottom:

uwsgi_param  UWSGI_SCHEME    $scheme;

This prompts uWSGI to set wsgi.url_scheme to the appropriate value, which Django then detects in the wsgi handler.

I'd really love to see this in the documentation on the uWSGI site, or (even better) included by default in the uwsgi_params in the tarball. In the meantime, though, it's a relatively quick and easy fix. Enjoy!

I’m a web application developer with nearly 15 years of experience creating high performance applications on the front & back end. I manage a team at Formidable Labs and help clients tackle big ideas.

View Comments