Brandon Konkle
Brandon Konkle

Principal Engineer, type system nerd, Rust enthusiast, supporter of social justice, loving husband & father, avid comic & manga reader, 日本語を勉強してる。

I’m a Software Architect with more than 15 years of experience creating high performance server and front-end applications targeting web and mobile platforms, & today I lead a team at Formidable Labs.

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 Software Architect with more than 15 years of experience creating high performance server and front-end applications targeting web and mobile platforms, & today I lead a team at Formidable Labs.

View Comments