pass HTTPS status from nginx to Django, closes #322
authorBryan <btbonval@gmail.com>
Fri, 7 Feb 2014 07:06:36 +0000 (02:06 -0500)
committerBryan <btbonval@gmail.com>
Fri, 7 Feb 2014 07:06:36 +0000 (02:06 -0500)
README.md
Vagrantfile

index cbd6365961b8af408b71f74b6035b66cb1cc1e45..720cec1453ea2976228a824de9232a6009b1536b 100644 (file)
--- 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;
             }
         }
 
index af39e3e89f77f6f1ea65e9223178d0818329fa01..93166c9cc990921ce82ab2954d0bbc5f193ab393 100644 (file)
@@ -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