From 9e38b20e8fcb84eeb4d5c3e772962b139192ecd8 Mon Sep 17 00:00:00 2001 From: Alberto Valverde Date: Mon, 8 Apr 2013 17:01:20 +0200 Subject: [PATCH] Added trust_xheaders config option to delegate it to HTTPServer. This is neccesary if the notebook app is proxied behind a reverse proxy that handles SSL. --- IPython/frontend/html/notebook/notebookapp.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/IPython/frontend/html/notebook/notebookapp.py b/IPython/frontend/html/notebook/notebookapp.py index 35a04485c..b138b710d 100644 --- a/IPython/frontend/html/notebook/notebookapp.py +++ b/IPython/frontend/html/notebook/notebookapp.py @@ -456,6 +456,11 @@ class NotebookApp(BaseIPythonApplication): config=True, help='The notebook manager class to use.') + trust_xheaders = Bool(False, config=True, + help=("Whether to trust or not X-Scheme/X-Forwarded-Proto and X-Real-Ip/X-Forwarded-For headers" + "sent by the upstream reverse proxy. Neccesary if the proxy handles SSL") + ) + def parse_command_line(self, argv=None): super(NotebookApp, self).parse_command_line(argv) if argv is None: @@ -508,7 +513,8 @@ class NotebookApp(BaseIPythonApplication): else: ssl_options = None self.web_app.password = self.password - self.http_server = httpserver.HTTPServer(self.web_app, ssl_options=ssl_options) + self.http_server = httpserver.HTTPServer(self.web_app, ssl_options=ssl_options, + xheaders=self.trust_xheaders) if not self.ip: warning = "WARNING: The notebook server is listening on all IP addresses" if ssl_options is None: