Browse Source

[core] configuration for load balancer that requires X-Forwarded-Host header

Romain Rigaux 10 years ago
parent
commit
ea3b7a2

+ 3 - 0
desktop/conf.dist/hue.ini

@@ -104,6 +104,9 @@
   # Use Google Analytics to see how many times an application or specific section of an application is used, nothing more.
   # Use Google Analytics to see how many times an application or specific section of an application is used, nothing more.
   ## collect_usage=true
   ## collect_usage=true
 
 
+  # Enable X-Forwarded-Host header if the load balancer requires it.
+  ## use_x_forwarded_host=false
+
   # Support for HTTPS termination at the load-balancer level with SECURE_PROXY_SSL_HEADER.
   # Support for HTTPS termination at the load-balancer level with SECURE_PROXY_SSL_HEADER.
   ## secure_proxy_ssl_header=false
   ## secure_proxy_ssl_header=false
 
 

+ 3 - 0
desktop/conf/pseudo-distributed.ini.tmpl

@@ -110,6 +110,9 @@
   # Use Google Analytics to see how many times an application or specific section of an application is used, nothing more.
   # Use Google Analytics to see how many times an application or specific section of an application is used, nothing more.
   ## collect_usage=true
   ## collect_usage=true
 
 
+  # Enable X-Forwarded-Host header if the load balancer requires it.
+  ## use_x_forwarded_host=false
+
   # Support for HTTPS termination at the load-balancer level with SECURE_PROXY_SSL_HEADER.
   # Support for HTTPS termination at the load-balancer level with SECURE_PROXY_SSL_HEADER.
   ## secure_proxy_ssl_header=false
   ## secure_proxy_ssl_header=false
 
 

+ 6 - 0
desktop/core/src/desktop/conf.py

@@ -217,6 +217,12 @@ REDIRECT_WHITELIST = Config(
   type=list_of_compiled_res(skip_empty=True),
   type=list_of_compiled_res(skip_empty=True),
   default='^\/.*$')
   default='^\/.*$')
 
 
+USE_X_FORWARDED_HOST = Config(
+  key="use_x_forwarded_host",
+  help=_("Enable X-Forwarded-Host header if the load balancer requires it."),
+  type=coerce_bool,
+  default=False)
+
 SECURE_PROXY_SSL_HEADER = Config(
 SECURE_PROXY_SSL_HEADER = Config(
   key="secure_proxy_ssl_header",
   key="secure_proxy_ssl_header",
   help=_("Support for HTTPS termination at the load-balancer level with SECURE_PROXY_SSL_HEADER."),
   help=_("Support for HTTPS termination at the load-balancer level with SECURE_PROXY_SSL_HEADER."),

+ 4 - 1
desktop/core/src/desktop/settings.py

@@ -393,7 +393,10 @@ if OAUTH_AUTHENTICATION:
 if desktop.conf.REDIRECT_WHITELIST.get():
 if desktop.conf.REDIRECT_WHITELIST.get():
   MIDDLEWARE_CLASSES.append('desktop.middleware.EnsureSafeRedirectURLMiddleware')
   MIDDLEWARE_CLASSES.append('desktop.middleware.EnsureSafeRedirectURLMiddleware')
 
 
-#Support HTTPS load-balancing
+# Enable X-Forwarded-Host header if the load balancer requires it
+USE_X_FORWARDED_HOST = desktop.conf.USE_X_FORWARDED_HOST.get()
+
+# Support HTTPS load-balancing
 if desktop.conf.SECURE_PROXY_SSL_HEADER.get():
 if desktop.conf.SECURE_PROXY_SSL_HEADER.get():
   SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTOCOL', 'https')
   SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTOCOL', 'https')