Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPython Notebook behind apache proxy #7898

Closed
franga2000 opened this issue Feb 28, 2015 · 7 comments
Closed

IPython Notebook behind apache proxy #7898

franga2000 opened this issue Feb 28, 2015 · 7 comments
Milestone

Comments

@franga2000
Copy link

Hi, 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 /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).

What am I doing wrong?

@franga2000 franga2000 changed the title IPython Notebook behing apache proxy IPython Notebook behind apache proxy Feb 28, 2015
@Carreau
Copy link
Member

Carreau commented Feb 28, 2015

This is just a warning, so I guess it should be fine.
(sidenote, you should run over https)

Did you had a look at #5525 ? (might have changed a bit)

Also ask on Mailing list for wider audience.

@franga2000
Copy link
Author

It is a warning, but it's returning HTTP 400 anyways. WebSockets aren't connecting so the app can't communicate with the kernel. Everything else works fine, I just can't execute any code.

I'm planning on using SSL, but I haven't started on that since I can't even get a normal connection to work.

I read #5525 but in the end everyone switched to nginx (can't do) and the solution was never posted.

@rgbkrk
Copy link
Member

rgbkrk commented Feb 28, 2015

I think your allowed origin should be without the path. That is, instead of

c.NotebookApp.allow_origin='http://127.0.0.1:8888/python'

It should read

c.NotebookApp.allow_origin='http://127.0.0.1:8888'

The Origin header is sent by the browser to indicate where a request _origin_ated from. This can be munged by Apache (I definitely don't know Apache though).

@franga2000
Copy link
Author

I changed the allow_origin and the apache header spoofer to 127.0.0.1:8080 and I still get the same errors. Debug mode isn't helpful either

@cabhishek
Copy link

@franga2000 Did you ever find a workaround? I'm having similar issues running IPython with apache httpd as reverse proxy.

@franga2000
Copy link
Author

@cabhishek Here's what worked for me: http://stackoverflow.com/a/28819231/1906127

@Carreau
Copy link
Member

Carreau commented Sep 13, 2015

Closing as there is a solution on SO post.

@Carreau Carreau closed this as completed Sep 13, 2015
@minrk minrk added this to the no action milestone Jan 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants