The Jupyter Notebook is a web application that allows you to create and share documents that contain live code, equations, visualizations and explanatory text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, machine learning and much more.

Jupyter project had a long history of development, It started with the Ipython project which provides a rich set of tools for computing and visualization with Python at it’s core. In the recent years the Ipython project broke into small components and the Kernel is the core of Jupyter.

Jupyter supports multiple programming languages.

For more information click here

Jupyter Installation

I would suggest installing from continuum anaconda project. It provides a seemless package management and virtual env setup tool. And also provides a rich set of libraries bundled with the setup. You can find the instruction here

Setting up the Notebook Server

You can start the notebook server as:

1
2
3
jupyter notebook
#for all the args
jupyter notebook --help-all

The Notebook is a Python tornado Server which serves the Terminal and kernel UI.

Demonizing the Notebook Server For Ubuntu

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
touch /etc/init/yourupstartjobname.conf
#content for your Upstart file
description "Service for jupyter notebook"
author      "You"

start on filesystem or runlevel [2345]
stop on shutdown
respawn

script
    echo $$ > /var/run/jupyter.pid
    exec /pathto/anaconda3/bin/jupyter notebook --no-browser 
    --NotebookApp.allow_origin='*' --notebook-dir='/pathtoworkspace'

end script

pre-stop script
    rm /var/run/jupyter.pid
end script

Setting Up Nginx server

As the Notebook server runs On Tornado which uses the websockets for some part of the Client Interaction. Standard nginx proxy pass uses the Http protocal. So we need to add some configuration to work.

For Interacting with the Terminal and And Kernel it uses the WSS(websocket protocal). You can find more about this here

Heres My Nginx configuation.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
upstream notebook {
    server localhost:8888;
}
server{
listen 80;
server_name xyz.abc.com;
location / {
        proxy_pass            http://notebook;
        proxy_set_header      Host $host;
}

location ~ /api/kernels/ {
        proxy_pass            http://notebook;
        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;
    }
location ~ /terminals/ {
        proxy_pass            http://notebook;
        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;
}
}

NOTE: If you are using Apache Server or AWS ELB you need similar kind of tweaks to work for you.