From 2de8ca08b7ef6d3db0db4dfe96f27234989c55fb Mon Sep 17 00:00:00 2001 From: Bryan Date: Fri, 7 Feb 2014 02:06:36 -0500 Subject: [PATCH] pass HTTPS status from nginx to Django, closes #322 --- README.md | 10 ++++++++++ Vagrantfile | 10 ++++++++++ 2 files changed, 20 insertions(+) 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 -- 2.25.1