4

I'm trying to get a reverse proxy (nginx) to work with juypterhub. I want the service available at myurl.com/jhub/. I placed the following in the config:

location /jhub/ {
        proxy_pass http://127.0.0.1:8000/;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_set_header X-NginX-Proxy true;  

        #WebSocket support

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 86400;
  }

However, when I try the url after restarting the proxy jupyterhub is not available and I get a '404' Not Found error. I've tried every combination of ports and address with no luck. The same approach works just fine for RStudio server.... What am I missing?

cel
  • 30,017
  • 18
  • 97
  • 117
  • 1
    have you set `c.JupyterHub.base_url` and `c.JupyterHub.hub_prefix` in your jupyterhub config file? – chilladx Mar 11 '16 at 10:10
  • thank you for the reply. I can't seem to find any documentation about how the `c.JupyterHub.hub_prefix` config works. – Isaac Faber Mar 12 '16 at 22:06
  • with a little bit of compromise I am just running the hub at `myurl.com/hub` but it remains a mystery to me how to use the proxy to reference some other url extension – Isaac Faber Mar 13 '16 at 19:23
  • 1
    Indeed, `c.JupyterHub.hub_prefix` seems deprecated, but `c.JupyterHub.base_url` seems to be the proper configuration. But as per https://gitter.im/jupyter/jupyterhub/archives/2015/11/03, you may need to kill the process called `configurable-http-proxy ` – chilladx Mar 14 '16 at 08:38
  • just be carefull - your example will not work with latest ipython, because cross scripting protection... chrome is sending in header field Origin ( which is not send by firefox), and as result, your nginx will not be working... you must add :$server_port to : proxy_set_header Host $host:$server_port; .... i stuck so many hours on this issue – Hynek Los kamute Jan 19 '17 at 18:37
  • @RandyLai I tried with your method but I get a 502 with nginx. In the log I have `*11 upstream prematurely closed connection while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: localhost, request: "GET /jupyterhub/ HTTP/1.1", upstream: "http://127.0.0.1:8000/jupyterhub", host: "hostdomain.com"` – Pincopallino Oct 12 '17 at 09:26

0 Answers0