Open jsalva opened 8 years ago
@rgbkrk ideas? @jsalva have you tried switch from 'localhost' to '127.0.0.1' explicitly?
I just tried updating every occurrence of localhost to 127.0.0.1 in ~/.jupyter/jupyter_notebook_config.py
, as well as in /etc/nginx/conf.d/configuration.conf
, to no avail
@jsalva did you get anywhere with this? I'm doing something similar with apache and running into the same problem.
I wish I could have some helpful updates, but nope, gave up and moved on.
I run mine behind a reverse proxy on Apache, and it took me a full evening of googling and editing my configuration and restarting, but I was able to get it with these directives:
<Location /notebook>
RequestHeader unset Accept-Encoding
ProxyPass http://notebook:8888/notebook
ProxyPassReverse http://notebook:8888/notebook
ProxyPreserveHost on
Order allow,deny
Allow from all
</Location>
<Location /notebook/api/kernels/>
ProxyPass ws://notebook:8888/notebook/api/kernels/
ProxyPassReverse ws://notebook:8888/notebook/api/kernels/
</Location>
Had to enable some additional modules for Apache for this to work (on Ubuntu 14.04 LTS):
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_https
sudo a2enmod proxy_wstunnel
sudo a2enmod headers
Also, in my .jupyter/jupyter_notebook_config.py I changed the base URL for the notebook (since it's being hosted as a virtual folder this makes the reverse proxying easier):
c.NotebookApp.base_url = '/notebook'
@ianabc @jsalva Feel free to ping me for discussion. I am not 100% sure what your situations are, or if this helps, and I am hardly an Apache guy, but I did manage to make it work.
@hosemn I was missing the proxy_wstunnel module, when turned on debugging I could see the protocol error. Thanks for your help!
Glad it worked for you, and I hope it helps other Apache users. As for nginx, I am not sure where to start.
Hmm, I also cannot get nginx proxy or a caddyserver proxy working. I can get pretty close, can log in and create and delete files, but cannot connect to a python kernel (or launch a terminal). Must have something to do with the websockets proxy, but it's beyond me. The Jupyter logs just show 400 errors like:
[W 01:51:26.202 NotebookApp] 400 GET /api/kernels/aa45474d-7fb8-4685-98dc-5ebeba378f41/channels?session_id=1A9BFB019EE0472486650C81705BCC73 (172.17.0.1) 5.77ms referer=None
My nginx conf is here: https://gist.github.com/cboettig/8643341bd3c93b62b5c2 (simple variations, e.g. serving from root instead of a subdomain, or serving without the ssl parts still give me the same issue). Any suggestions?
Don't know if it will help, but here is a working nginx config file for jupyterhub:
On Wed, Dec 30, 2015 at 6:01 PM, Carl Boettiger notifications@github.com wrote:
Hmm, I also cannot get nginx proxy or a caddyserver proxy working. I can get pretty close, can log in and create and delete files, but cannot connect to a python kernel (or launch a terminal). Must have something to do with the websockets proxy, but it's beyond me. The Jupyter logs just show 400 errors like: [W 01:51:26.202 NotebookApp] 400 GET /api/kernels/aa45474d-7fb8-4685-98dc-5ebeba378f41/channels?session_id=1A9BFB019EE0472486650C81705BCC73 (172.17.0.1) 5.77ms referer=None
My nginx conf is here: https://gist.github.com/cboettig/8643341bd3c93b62b5c2 (simple variations, e.g. serving from root instead of a subdomain, or serving without the ssl parts still give me the same issue). Any suggestions?
— Reply to this email directly or view it on GitHub https://github.com/jupyter/notebook/issues/625#issuecomment-168110162.
Brian E. Granger Associate Professor of Physics and Data Science Cal Poly State University, San Luis Obispo @ellisonbg on Twitter and GitHub bgranger@calpoly.edu and ellisonbg@gmail.com
@ellisonbg Thanks for the suggestion, I've actually tried that config as well (after putting in the appropriate values for the ansible-template chunks), and I get the exact same issue -- nginx shows 400 errors trying to connect to the kernel, and Jupyter opens but cannot reach a python kernel...
I'm running the jupyter instance via a docker container from jupyter/docker-stacks; but don't see why that should be messing up the connection to the kernel when behind a proxy...
@cboettig Exact same issue here (using nginx in front of https://hub.docker.com/r/jupyter/jupyterhub/~/dockerfile/ ). No idea what could be wrong.
nginx tells me "client closed connection while waiting for request"
Update: Turns out my issue was that my nginx server was behind an aws ELB (for https). ELBs need special configs for websockets. I ended up just bypassing the ELB.
@rcompton Thanks, turned out my issue was also websockets related (and had hub
-style redirects with user
bit in my previous file). Here's the tweaked nginx working for me now: https://gist.github.com/cboettig/8643341bd3c93b62b5c2
It works for me using jsalva's config with one small change:
location ~ /api/kernels/ {
@nicerobot's suggestion worked for me. Thanks!
This worked for me, based on jsalva's post (behind VPN so no SSL):
server {
listen 80 default_server;
location / {
proxy_pass http://localhost:{{ jupyter_server_port }};
proxy_set_header Host $host;
}
location /api/kernels/ {
proxy_pass http://localhost:{{ jupyter_server_port }};
proxy_set_header Host $host;
# websocket support
proxy_http_version 1.1;
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "Upgrade";
proxy_read_timeout 86400;
}
}
Just ran into this issue, and tried the solution by @qqrs, but it isn't exactly future-proof and some functionalities like spawning terminals still didn't work. I dug a little deeper and found that websockets in Nginx only needs a specified http version, and being able to upgrade the connection into a tunnel. I currently have this config working:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name jupyter.somewhere.cool;
location / {
proxy_pass http://localhost:9999;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
@wintermelons it's awesome, you saved my day!
I'm still getting the same error even with the solution by @qqrs above. I'm running the notebook server in gcloud with https and OAuth2. Has anyone managed to get it to work in a similar setup?
Using proxy_set_header Host $host;
doesn't work for me. I got "API request failed (403): Forbidden" when I clicked "Stop My Server" button. Error from Jupyterhub log:
403 DELETE /hub/api/users/tester/server (@10.10.102.28)
Changing to proxy_set_header Host $http_host;
does solve my issue. So now when I clicked the button, Jupyterhub produce log output with:
204 DELETE /hub/api/users/tester/server (tester@10.10.102.28)
I'm running Jupyter behind an ssl reverse proxy. @wintermelons solution did work for me, when accessing the notebook from Firefox - but not from Safari where I cannot connect to the notebook kernel and get a 401 error on the web socket call:
[Error] WebSocket connection to 'wss://somedomain.com/notebooks/api/kernels/6343900b-12f3-4245-81cd-8c1e3642d6b5/channels?session_id=DF7A59E736A041458B79DD76D45AC89B' failed: Unexpected response code: 401
Maybe that does explain the different results people are reporting here.
I have to set proxy_read_timeout
to a large value like 86400, otherwise, browser console continues reconnecting. https://github.com/jupyterhub/jupyterhub/issues/3368
I have to set
proxy_read_timeout
to a large value like 86400, otherwise, browser console continues reconnecting. jupyterhub/jupyterhub#3368
proxy_read_timeout = 60s
is enough. Because the ping-pong interval is 30s
For me proxy_set_header Origin "";
solved the problem (SSL on).
Reference (in the comments): https://stackoverflow.com/a/23912400
Thanks for your code. I advise you to check also if the configuration file (a python file) has no coding error
Thanks to whoever mentioned web sockets. I am using nginx proxy manager for reverse proxy and all I had to do was tick the "websockets support" to ON for jupyter. This fixed the "400 GET" error logs towards api/kernels in the docker container for jupyer.
this helped me
ingress:
enabled: true
annotations:
nginx.org/websocket-services: "proxy-public"
hosts:
- example.com
I used helm chart
Hi guys,
I've been trying to get my jupyter notebook to run behind an nginx reverse proxy and everything seems to be going well, until i actually try to connect to the kernel in a notebook. Here's my
/etc/nginx/conf.d/configuration.conf
configuration upfront:Also, here's my
~/.jupyter/jupyter_notebook_config.py
:On the client, the
<div id="notification_kernel">...</div>
won't stop displaying "connecting to kernel", and I can't get my cells to run.As it retries, I get a popup with "A connection to the notebook server could not be established. The notebook will continue trying to reconnect, but until it does, you will NOT be able to run code. Check your network connection or notebook server configuration."
and, the javascript console:
(Edit: I just noticed that in the above javascript console output, the id following the
kernel_created
message is different from all the other ids used in e.g. the kernel URLs; my guess is that isn't relevant at all, but I'm running out of ideas...)from the server's perspective (loglevel "DEBUG"):
The only way I got the websockets to connect to the kernel properly was to bypass nginx and set
Then, when I access it from the
https://ec2-url-for-my-instance:8888
(after clicking through the security warnings that pop up with my self-signed certificate), the websockets will connect to the kernel and I can go on my merry way running whatever I want...I have been trying to determine why the nginx proxy isn't working for almost 2 days now.
Does anyone have any ideas about what's going on?