Skip to content

Instantly share code, notes, and snippets.

@mgagne
Last active September 4, 2015 21:02
Show Gist options
  • Save mgagne/b4c817cd2aa86b37daee to your computer and use it in GitHub Desktop.
Save mgagne/b4c817cd2aa86b37daee to your computer and use it in GitHub Desktop.
Add support for X-Forwarded-Proto header
From 16b30640057635cb6172888eec36961c6bcfd305 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mathieu=20Gagne=CC=81?= <[email protected]>
Date: Fri, 4 Sep 2015 16:46:08 -0400
Subject: [PATCH] Add support for X-Forwarded-Proto header
This header allows the application to build proper URLs
when SSL termination is performed upstream.
Change-Id: I22cd74f03adea903c1763a59b5c863e2236db7dc
---
nova/api/openstack/urlmap.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/nova/api/openstack/urlmap.py b/nova/api/openstack/urlmap.py
index 9c35bd3..d40ddb7 100644
--- a/nova/api/openstack/urlmap.py
+++ b/nova/api/openstack/urlmap.py
@@ -236,6 +236,9 @@ class URLMap(paste.urlmap.URLMap):
return mime_type, app
def __call__(self, environ, start_response):
+ proto = environ.get('HTTP_X_FORWARDED_PROTO', None)
+ if proto in ('http', 'https'):
+ environ['wsgi.url_scheme'] = proto
host = environ.get('HTTP_HOST', environ.get('SERVER_NAME')).lower()
if ':' in host:
host, port = host.split(':', 1)
--
1.7.12.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment