1

I'm trying to run iPython Notebook behind an Apache2 proxy and I'm having trouble with WebSockets.

I'd like to have the notebook accessible from <domain>/python/.

Using a few tutorials and the apache wiki, I managed to write this VirtualHosts file:

# Trying to proxy WS requests
ProxyPass /python/api/kernels ws://127.0.0.1:8888/python/api/kernels
ProxyPassReverse /python/api/kernels ws://127.0.0.1:8888/python/api/kernels

# Proxy HTTP requests
ProxyPass /python http://127.0.0.1:8888/python
ProxyPassReverse /python http://127.0.0.1:8888/python
ProxyRequests On

# Spoof headers only if the URL contains "/python/" (I have other stuff on this VHost)
<If "%{QUERY_STRING} =~ /python/">
   Header set Host "http://127.0.0.1:8888/python"
   Header set Origin "http://127.0.0.1:8888/python"

   RequestHeader set Host "http://127.0.0.1:8888/python"
   RequestHeader set Origin "http://127.0.0.1:8888/python"
</If>

Here's my notebook profile config:

c = get_config()

c.NotebookApp.ip = '127.0.0.1'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888

c.NotebookApp.base_url = '/python/'
c.NotebookApp.tornado_settings = {'static_url_prefix':'/python/static/'}
c.NotebookApp.allow_origin='http://127.0.0.1:8888/python'
c.NotebookApp.notebook_dir = '/home/franga2000/iPython/'

I'm getting this error in the NB console (also for /stdin and /iopub:

WARNING:tornado.access:400 GET /python/api/kernels/f2d21678-4fef-4cb4-996f-dcee954b54ca/shell (127.0.0.1) 0.44ms referer=None

I'm using Apache 2.4.7 on Ubuntu 14.04. Also, the notebook is runing in a virtualenv (doubt its relevant).

Does anyone know a way to do this (without switching to nginx)?

jww
  • 97,681
  • 90
  • 411
  • 885
franga2000
  • 587
  • 1
  • 9
  • 19
  • This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. – jww Feb 22 '15 at 08:19
  • Not the first time something like this was posted here: http://stackoverflow.com/questions/23890386/how-to-run-ipython-behind-an-apache-proxy and even the official website recommend SO for support – franga2000 Feb 22 '15 at 08:35
  • No, but this question was on the homepage while I was cleaning it up. If the question you cited is off-topic, then you should flag it as such. Or maybe this question is a duplicate of that question ;) – jww Feb 22 '15 at 08:36
  • Both of these questions are completely on topic and they are not the same. – franga2000 Feb 22 '15 at 08:48
  • Finally found a working solution: http://stackoverflow.com/a/28819231/1906127 – franga2000 Jun 13 '15 at 09:05

0 Answers0