From: Bryan Date: Fri, 7 Feb 2014 07:06:36 +0000 (-0500) Subject: pass HTTPS status from nginx to Django, closes #322 X-Git-Tag: release-20150131~176 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2de8ca08b7ef6d3db0db4dfe96f27234989c55fb;p=oweals%2Fkarmaworld.git pass HTTPS status from nginx to Django, closes #322 --- diff --git a/README.md b/README.md index cbd6365..720cec1 100644 --- a/README.md +++ b/README.md @@ -317,6 +317,16 @@ not generally be needed. location / { # pass traffic through to gunicorn proxy_pass http://127.0.0.1:8000; + # pass HTTP(S) status through to Django + if ($scheme ~ http) { + set $ssl 'off'; + } + if ($scheme ~ https) { + set $ssl 'on'; + } + proxy_set_header X-Forwarded-SSL $ssl; + proxy_set_header X-Forwarded-Protocol $scheme; + proxy_set_header X-Forwarded-Proto $scheme; } } diff --git a/Vagrantfile b/Vagrantfile index af39e3e..93166c9 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -116,6 +116,16 @@ server { location / { # pass traffic through to gunicorn proxy_pass http://127.0.0.1:8000; + # pass HTTP(S) status through to Django + if (\\\$scheme ~ http) { + set \\\$ssl 'off'; + } + if (\\\$scheme ~ https) { + set \\\$ssl 'on'; + } + proxy_set_header X-Forwarded-SSL \\\$ssl; + proxy_set_header X-Forwarded-Protocol \\\$scheme; + proxy_set_header X-Forwarded-Proto \\\$scheme; } } CONFIG