Skip to content

Deployment Overview of Jupyter Notebook on Server

Prerequisites and Basic Requirements

The application requires a server running Ubuntu to ensure compatibility with the installation scripts. The following system requirements and configurations must be met:

  • Operating System: Ubuntu

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

  • Ports:

  • 443 (External HTTPS access)

  • 8888 (Internal application port)

FQDN of the final panel on the hostkey.in domain

The application is accessible via a specific subdomain template 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 deployment utilizes several specific directories for data, configuration, and proxy management:

  • /opt/data: Main application data directory.

  • /opt/data/jupyter: Python virtual environment and Jupyter workspace.

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

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

  • /data/nginx/user_conf.d/: Custom Nginx user configurations.

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

Application installation process

The installation follows a multi-step process involving system package management and Python environment setup:

  1. System Dependencies: The system is updated, and essential packages are installed via apt, including python3, python3-pip, jupyter, and python3-virtualenv.

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

  3. Virtual Environment Creation: A Python virtual environment is initialized at /opt/data/jupyter under the jupyter user.

  4. Python Package Installation: The following packages are installed within the virtual environment:

  5. notebook

  6. voila

  7. virtualenv

  8. jupyter-server

  9. Configuration Generation:

  10. A Jupyter configuration file is generated.

  11. Security settings are applied to allow cross-origin requests (c.ServerApp.allow_origin = '*').

  12. An authentication password is automatically generated and configured for the server.

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

Access Rights and Security

  • User Isolation: The core application runs under the jupyter user, while the reverse proxy handles external traffic.

  • Firewall: External access is restricted to port 443.

  • Authentication: Access to the Jupyter interface is protected by a password generated during installation.

Docker Containers and Their Deployment

The deployment utilizes a Docker container to manage SSL certificates and Nginx reverse proxying 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: Shared volume for SSL certificates.

  • /data/nginx/user_conf.d:/etc/nginx/user_conf.d: Custom Nginx configuration files.

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

  • Environment Variables:

  • [email protected] (Configured via .env file).

  • Restart Policy: unless-stopped

Custom Scripts and Additional Setup

The deployment performs several automated configuration steps:

  • Password Generation: An automated process executes /opt/data/jupyter/bin/jupyter notebook password to secure the instance.

  • Service Initialization: The systemd service is configured to start automatically on boot, pointing to the specific virtual environment and working directory (/opt/data).

Application Update Instructions

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

  1. Ensure the Python virtual environment is active or use the absolute path to the pip binary.

  2. Upgrade the core packages using pip:

    /opt/data/jupyter/bin/pip install --upgrade notebook voila jupyter-server
    

Location of configuration files and data

Component Path
Jupyter Configuration /root/.jupyter/jupyter_notebook_config.py
Application Data /opt/data/jupyter/share/jupyter
Nginx Configs /data/nginx/user_conf.d/

Available ports for connection

  • HTTPS (External): 443

  • Jupyter Internal: 8888

Starting and Stopping the application

The application is managed via systemd.

Start the application:

sudo systemctl start jupyter-notebook

Stop the application:

sudo systemctl stop jupyter-notebook

Check status:

sudo systemctl status jupyter-notebook

Proxy Servers

The deployment uses an Nginx container managed by nginx-certbot. This setup handles SSL termination via Let's Encrypt and provides a secure HTTPS entry point for the Jupyter Notebook instance. The configuration is driven by files located in /data/nginx/user_conf.d/ and environment variables defined in /data/nginx/nginx-certbot.env.

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