Skip to content

Deployment Overview of Jupyter Notebook on Server

Prerequisites and Basic Requirements

To ensure a successful deployment, the following requirements must be met:

  • Operating System: Ubuntu (recommended).

  • Privileges: Root or sudo access is required for package installation and service management.

  • Python Environment: Python 3 and pip are required for the virtual environment setup.

  • Docker: Docker and Docker Compose must be installed to run the Nginx reverse proxy with SSL support.

FQDN of the final panel on the hostkey.in domain

The application is accessible via a specific subdomain based on the server ID.

Parameter Value
Prefix notebook
Domain hostkey.in
Full template notebook{Server_ID_from_Invapi}.hostkey.in

File and Directory Structure

The following directories are used for application data, configurations, and proxy management:

  • /opt/data: Main data directory for Jupyter Notebook.

  • /opt/data/jupyter: Python virtual environment and notebook files.

  • /root/.jupyter/: Jupyter configuration files.

  • /root/nginx/: Nginx Docker Compose configuration and deployment files.

  • /data/nginx/user_conf.d/: Custom Nginx configuration files for the proxy.

  • /data/nginx/nginx-certbot.env: Environment variables for the Nginx container.

Application installation process

The installation follows a two-stage process involving system package installation and Docker deployment:

  1. System Dependencies: The installer installs python3, python3-pip, jupyter, and python3-virtualenv via the apt package manager.

  2. User Setup: A dedicated system user named jupyter (UID 2841) is created to manage the application environment.

  3. Virtual Environment: A Python virtual environment is initialized in /opt/data/jupyter.

  4. Application Installation: The following packages are installed within the virtual environment via pip:

  5. notebook

  6. voila

  7. virtualenv

  8. jupyter-server

  9. Configuration Generation: Jupyter configuration files are generated, and security settings (such as CORS origin) are applied to /root/.jupyter/jupyter_notebook_config.py.

  10. Service Configuration: A systemd service unit is created at /usr/lib/systemd/system/jupyter-notebook.service to manage the application process.

  11. Proxy Deployment: A Docker container running jonasal/nginx-certbot:latest is deployed via Docker Compose in /root/nginx/ to handle SSL termination and reverse proxying.

Access Rights and Security

  • User Isolation: The Jupyter processes run under the jupyter user for security, while the systemd service manages the execution from a controlled environment.

  • Firewall: The application is intended to be accessed via HTTPS (Port 443).

  • Authentication: A password is generated during installation to secure the Jupyter Notebook interface.

Databases

No external database management system is required for this deployment, as it utilizes local file storage for notebook data and configuration.

Docker Containers and Their Deployment

The deployment includes one primary application container managed via Docker Compose:

Nginx Proxy Container

  • Image: jonasal/nginx-certbot:latest

  • Ports: Uses host network mode to bind directly to host ports.

  • Volumes:

  • nginx_secrets:/etc/letsencrypt: For SSL certificate storage.

  • /data/nginx/user_conf.d:/etc/nginx/user_conf.d: For custom Nginx site configurations.

  • /home:/home: Access to host home directories.

  • Environment Variables: CERTBOT_EMAIL is set for Let's Encrypt communications.

  • Restart Policy: unless-stopped.

Custom Scripts and Additional Setup

The installation performs several automated setup actions:

  • Password Generation: Automatically sets a Jupyter Notebook password using the provided credentials.

  • Systemd Integration: Configures the application to start automatically on system boot via systemd.

  • Environment Configuration: Modifies Jupyter configuration files to allow cross-origin requests (c.ServerApp.allow_origin = '*').

Application Update Instructions

To update the main Jupyter Notebook application, follow these steps:

  1. If updating the proxy layer, navigate to /root/nginx and run:

    docker compose pull && docker compose up -d
    

  2. For the core Jupyter application, ensure the virtual environment is updated via pip within the /opt/data/jupyter directory.

Location of configuration files and data

  • Jupyter Config: /root/.jupyter/jupyter_notebook_config.py and /root/.jupyter/jupyter_server_config.json.

  • Application Data: /opt/data/jupyter/share/jupyter.

  • Nginx Configuration: /data/nginx/user_conf.d/.

Available ports for connection

  • HTTPS: 443 (via Nginx Proxy).

  • Internal Jupyter Port: 8888 (accessible via the proxy).

Starting and Stopping the application

The application is managed as a system service:

  • Start Jupyter Notebook:

    systemctl start jupyter-notebook
    

  • Stop Jupyter Notebook:

    systemctl stop jupyter-notebook
    

  • Enable on Boot:

    systemctl enable jupyter-notebook
    

Proxy Servers

The application uses an Nginx container with Certbot integration to provide SSL/TLS encryption. The proxy handles incoming traffic on port 443 and forwards it to the Jupyter Notebook service running locally. Custom domain routing is managed through configuration files located in /data/nginx/user_conf.d/.

question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×